Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ANDROID_SF_HWCOMPOSER_H |
| 18 | #define ANDROID_SF_HWCOMPOSER_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/types.h> |
| 22 | |
Mathias Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 23 | #include <hardware/hwcomposer_defs.h> |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 24 | |
Jamie Gennis | 2ec3e07 | 2012-11-11 16:24:33 -0800 | [diff] [blame] | 25 | #include <ui/Fence.h> |
| 26 | |
| 27 | #include <utils/BitSet.h> |
Mathias Agopian | 921e6ac | 2012-07-23 23:11:29 -0700 | [diff] [blame] | 28 | #include <utils/Condition.h> |
| 29 | #include <utils/Mutex.h> |
Mathias Agopian | c7d14e2 | 2011-08-01 16:32:21 -0700 | [diff] [blame] | 30 | #include <utils/StrongPointer.h> |
Mathias Agopian | 921e6ac | 2012-07-23 23:11:29 -0700 | [diff] [blame] | 31 | #include <utils/Thread.h> |
| 32 | #include <utils/Timers.h> |
Mathias Agopian | 22da60c | 2011-09-09 00:49:11 -0700 | [diff] [blame] | 33 | #include <utils/Vector.h> |
Mathias Agopian | c7d14e2 | 2011-08-01 16:32:21 -0700 | [diff] [blame] | 34 | |
Mathias Agopian | 3eb38cb | 2012-04-03 22:09:52 -0700 | [diff] [blame] | 35 | extern "C" int clock_nanosleep(clockid_t clock_id, int flags, |
| 36 | const struct timespec *request, |
| 37 | struct timespec *remain); |
| 38 | |
Jesse Hall | 5880cc5 | 2012-06-05 23:40:32 -0700 | [diff] [blame] | 39 | struct hwc_composer_device_1; |
Jesse Hall | b685c54 | 2012-07-31 14:32:56 -0700 | [diff] [blame] | 40 | struct hwc_display_contents_1; |
Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 41 | struct hwc_layer_1; |
Mathias Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 42 | struct hwc_procs; |
Mathias Agopian | 8b736f1 | 2012-08-13 17:54:26 -0700 | [diff] [blame] | 43 | struct framebuffer_device_t; |
Mathias Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 44 | |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 45 | namespace android { |
| 46 | // --------------------------------------------------------------------------- |
| 47 | |
Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 48 | class Fence; |
Mathias Agopian | 6b44267 | 2013-07-09 21:24:52 -0700 | [diff] [blame] | 49 | class FloatRect; |
Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame^] | 50 | class GraphicBuffer; |
| 51 | class NativeHandle; |
Jamie Gennis | 1a4d883 | 2012-08-02 20:11:05 -0700 | [diff] [blame] | 52 | class Region; |
Mathias Agopian | 8372785 | 2010-09-23 18:13:21 -0700 | [diff] [blame] | 53 | class String8; |
Mathias Agopian | c7d14e2 | 2011-08-01 16:32:21 -0700 | [diff] [blame] | 54 | class SurfaceFlinger; |
Mathias Agopian | 8372785 | 2010-09-23 18:13:21 -0700 | [diff] [blame] | 55 | |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 56 | class HWComposer |
| 57 | { |
| 58 | public: |
Mathias Agopian | 3eb38cb | 2012-04-03 22:09:52 -0700 | [diff] [blame] | 59 | class EventHandler { |
| 60 | friend class HWComposer; |
Jesse Hall | 1bd20e0 | 2012-08-29 10:47:52 -0700 | [diff] [blame] | 61 | virtual void onVSyncReceived(int disp, nsecs_t timestamp) = 0; |
Mathias Agopian | 148994e | 2012-09-19 17:31:36 -0700 | [diff] [blame] | 62 | virtual void onHotplugReceived(int disp, bool connected) = 0; |
Mathias Agopian | 3eb38cb | 2012-04-03 22:09:52 -0700 | [diff] [blame] | 63 | protected: |
| 64 | virtual ~EventHandler() {} |
| 65 | }; |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 66 | |
Mathias Agopian | 1e26087 | 2012-08-08 18:35:12 -0700 | [diff] [blame] | 67 | enum { |
Jesse Hall | 9e663de | 2013-08-16 14:28:37 -0700 | [diff] [blame] | 68 | NUM_BUILTIN_DISPLAYS = HWC_NUM_PHYSICAL_DISPLAY_TYPES, |
| 69 | MAX_HWC_DISPLAYS = HWC_NUM_DISPLAY_TYPES, |
| 70 | VIRTUAL_DISPLAY_ID_BASE = HWC_DISPLAY_VIRTUAL, |
Mathias Agopian | 1e26087 | 2012-08-08 18:35:12 -0700 | [diff] [blame] | 71 | }; |
| 72 | |
Mathias Agopian | 8b736f1 | 2012-08-13 17:54:26 -0700 | [diff] [blame] | 73 | HWComposer( |
| 74 | const sp<SurfaceFlinger>& flinger, |
Andy McFadden | b0d1dd3 | 2012-09-10 14:08:09 -0700 | [diff] [blame] | 75 | EventHandler& handler); |
Mathias Agopian | 8b736f1 | 2012-08-13 17:54:26 -0700 | [diff] [blame] | 76 | |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 77 | ~HWComposer(); |
| 78 | |
| 79 | status_t initCheck() const; |
| 80 | |
Jesse Hall | 9e663de | 2013-08-16 14:28:37 -0700 | [diff] [blame] | 81 | // Returns a display ID starting at VIRTUAL_DISPLAY_ID_BASE, this ID is to |
| 82 | // be used with createWorkList (and all other methods requiring an ID |
| 83 | // below). |
| 84 | // IDs below NUM_BUILTIN_DISPLAYS are pre-defined and therefore are |
| 85 | // always valid. |
| 86 | // Returns -1 if an ID cannot be allocated |
Mathias Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 87 | int32_t allocateDisplayId(); |
| 88 | |
Jesse Hall | 9e663de | 2013-08-16 14:28:37 -0700 | [diff] [blame] | 89 | // Recycles the given virtual display ID and frees the associated worklist. |
| 90 | // IDs below NUM_BUILTIN_DISPLAYS are not recycled. |
Mathias Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 91 | status_t freeDisplayId(int32_t id); |
| 92 | |
| 93 | |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 94 | // Asks the HAL what it can do |
Mathias Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 95 | status_t prepare(); |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 96 | |
| 97 | // commits the list |
Mathias Agopian | 30bcc61 | 2012-08-22 15:39:48 -0700 | [diff] [blame] | 98 | status_t commit(); |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 99 | |
Colin Cross | 10fbdb6 | 2012-07-12 17:56:34 -0700 | [diff] [blame] | 100 | // release hardware resources and blank screen |
Mathias Agopian | 81cd5d3 | 2012-10-04 02:34:38 -0700 | [diff] [blame] | 101 | status_t release(int disp); |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 102 | |
Colin Cross | 10fbdb6 | 2012-07-12 17:56:34 -0700 | [diff] [blame] | 103 | // acquire hardware resources and unblank screen |
Mathias Agopian | 81cd5d3 | 2012-10-04 02:34:38 -0700 | [diff] [blame] | 104 | status_t acquire(int disp); |
Colin Cross | 10fbdb6 | 2012-07-12 17:56:34 -0700 | [diff] [blame] | 105 | |
Andy McFadden | 27ec573 | 2012-10-02 19:04:45 -0700 | [diff] [blame] | 106 | // reset state when an external, non-virtual display is disconnected |
| 107 | void disconnectDisplay(int disp); |
| 108 | |
Mathias Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 109 | // create a work list for numLayers layer. sets HWC_GEOMETRY_CHANGED. |
Mathias Agopian | 1e26087 | 2012-08-08 18:35:12 -0700 | [diff] [blame] | 110 | status_t createWorkList(int32_t id, size_t numLayers); |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 111 | |
Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 112 | bool supportsFramebufferTarget() const; |
| 113 | |
Mathias Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 114 | // does this display have layers handled by HWC |
| 115 | bool hasHwcComposition(int32_t id) const; |
| 116 | |
| 117 | // does this display have layers handled by GLES |
| 118 | bool hasGlesComposition(int32_t id) const; |
Mathias Agopian | 9c6e297 | 2011-09-20 17:21:56 -0700 | [diff] [blame] | 119 | |
Jesse Hall | 80e0a39 | 2013-03-15 12:32:10 -0700 | [diff] [blame] | 120 | // get the releaseFence file descriptor for a display's framebuffer layer. |
Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 121 | // the release fence is only valid after commit() |
Jesse Hall | 13f01cb | 2013-03-20 11:37:21 -0700 | [diff] [blame] | 122 | sp<Fence> getAndResetReleaseFence(int32_t id); |
Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 123 | |
Mathias Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 124 | // needed forward declarations |
| 125 | class LayerListIterator; |
| 126 | |
Mathias Agopian | cde87a3 | 2012-09-13 14:09:01 -0700 | [diff] [blame] | 127 | // return the visual id to be used to find a suitable EGLConfig for |
| 128 | // *ALL* displays. |
| 129 | int getVisualID() const; |
| 130 | |
Andy McFadden | b0d1dd3 | 2012-09-10 14:08:09 -0700 | [diff] [blame] | 131 | // Forwarding to FB HAL for pre-HWC-1.1 code (see FramebufferSurface). |
Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 132 | int fbPost(int32_t id, const sp<Fence>& acquireFence, const sp<GraphicBuffer>& buf); |
Andy McFadden | b0d1dd3 | 2012-09-10 14:08:09 -0700 | [diff] [blame] | 133 | int fbCompositionComplete(); |
| 134 | void fbDump(String8& result); |
| 135 | |
Jesse Hall | 851cfe8 | 2013-03-20 13:44:00 -0700 | [diff] [blame] | 136 | // Set the output buffer and acquire fence for a virtual display. |
| 137 | // Returns INVALID_OPERATION if id is not a virtual display. |
| 138 | status_t setOutputBuffer(int32_t id, const sp<Fence>& acquireFence, |
| 139 | const sp<GraphicBuffer>& buf); |
| 140 | |
| 141 | // Get the retire fence for the last committed frame. This fence will |
| 142 | // signal when the h/w composer is completely finished with the frame. |
| 143 | // For physical displays, it is no longer being displayed. For virtual |
| 144 | // displays, writes to the output buffer are complete. |
| 145 | sp<Fence> getLastRetireFence(int32_t id); |
| 146 | |
Mathias Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 147 | /* |
| 148 | * Interface to hardware composer's layers functionality. |
| 149 | * This abstracts the HAL interface to layers which can evolve in |
| 150 | * incompatible ways from one release to another. |
| 151 | * The idea is that we could extend this interface as we add |
| 152 | * features to h/w composer. |
| 153 | */ |
| 154 | class HWCLayerInterface { |
| 155 | protected: |
| 156 | virtual ~HWCLayerInterface() { } |
| 157 | public: |
| 158 | virtual int32_t getCompositionType() const = 0; |
| 159 | virtual uint32_t getHints() const = 0; |
Jesse Hall | 13f01cb | 2013-03-20 11:37:21 -0700 | [diff] [blame] | 160 | virtual sp<Fence> getAndResetReleaseFence() = 0; |
Mathias Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 161 | virtual void setDefaultState() = 0; |
| 162 | virtual void setSkip(bool skip) = 0; |
| 163 | virtual void setBlending(uint32_t blending) = 0; |
| 164 | virtual void setTransform(uint32_t transform) = 0; |
| 165 | virtual void setFrame(const Rect& frame) = 0; |
Mathias Agopian | 6b44267 | 2013-07-09 21:24:52 -0700 | [diff] [blame] | 166 | virtual void setCrop(const FloatRect& crop) = 0; |
Mathias Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 167 | virtual void setVisibleRegionScreen(const Region& reg) = 0; |
Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame^] | 168 | virtual void setSidebandStream(const sp<NativeHandle>& stream) = 0; |
Mathias Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 169 | virtual void setBuffer(const sp<GraphicBuffer>& buffer) = 0; |
Jesse Hall | dc5b485 | 2012-06-29 15:21:18 -0700 | [diff] [blame] | 170 | virtual void setAcquireFenceFd(int fenceFd) = 0; |
Mathias Agopian | 9f8386e | 2013-01-29 18:56:42 -0800 | [diff] [blame] | 171 | virtual void setPlaneAlpha(uint8_t alpha) = 0; |
Mathias Agopian | c397360 | 2012-08-31 17:51:25 -0700 | [diff] [blame] | 172 | virtual void onDisplayed() = 0; |
Mathias Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 173 | }; |
| 174 | |
| 175 | /* |
| 176 | * Interface used to implement an iterator to a list |
| 177 | * of HWCLayer. |
| 178 | */ |
| 179 | class HWCLayer : public HWCLayerInterface { |
| 180 | friend class LayerListIterator; |
| 181 | // select the layer at the given index |
| 182 | virtual status_t setLayer(size_t index) = 0; |
| 183 | virtual HWCLayer* dup() = 0; |
| 184 | static HWCLayer* copy(HWCLayer *rhs) { |
| 185 | return rhs ? rhs->dup() : NULL; |
| 186 | } |
| 187 | protected: |
| 188 | virtual ~HWCLayer() { } |
| 189 | }; |
| 190 | |
| 191 | /* |
| 192 | * Iterator through a HWCLayer list. |
| 193 | * This behaves more or less like a forward iterator. |
| 194 | */ |
| 195 | class LayerListIterator { |
| 196 | friend struct HWComposer; |
| 197 | HWCLayer* const mLayerList; |
| 198 | size_t mIndex; |
| 199 | |
| 200 | LayerListIterator() : mLayerList(NULL), mIndex(0) { } |
| 201 | |
| 202 | LayerListIterator(HWCLayer* layer, size_t index) |
| 203 | : mLayerList(layer), mIndex(index) { } |
| 204 | |
| 205 | // we don't allow assignment, because we don't need it for now |
| 206 | LayerListIterator& operator = (const LayerListIterator& rhs); |
| 207 | |
| 208 | public: |
| 209 | // copy operators |
| 210 | LayerListIterator(const LayerListIterator& rhs) |
| 211 | : mLayerList(HWCLayer::copy(rhs.mLayerList)), mIndex(rhs.mIndex) { |
| 212 | } |
| 213 | |
| 214 | ~LayerListIterator() { delete mLayerList; } |
| 215 | |
| 216 | // pre-increment |
| 217 | LayerListIterator& operator++() { |
| 218 | mLayerList->setLayer(++mIndex); |
| 219 | return *this; |
| 220 | } |
| 221 | |
| 222 | // dereference |
| 223 | HWCLayerInterface& operator * () { return *mLayerList; } |
| 224 | HWCLayerInterface* operator -> () { return mLayerList; } |
| 225 | |
| 226 | // comparison |
| 227 | bool operator == (const LayerListIterator& rhs) const { |
| 228 | return mIndex == rhs.mIndex; |
| 229 | } |
| 230 | bool operator != (const LayerListIterator& rhs) const { |
| 231 | return !operator==(rhs); |
| 232 | } |
| 233 | }; |
| 234 | |
| 235 | // Returns an iterator to the beginning of the layer list |
Mathias Agopian | 1e26087 | 2012-08-08 18:35:12 -0700 | [diff] [blame] | 236 | LayerListIterator begin(int32_t id); |
Mathias Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 237 | |
| 238 | // Returns an iterator to the end of the layer list |
Mathias Agopian | 1e26087 | 2012-08-08 18:35:12 -0700 | [diff] [blame] | 239 | LayerListIterator end(int32_t id); |
Mathias Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 240 | |
| 241 | |
Mathias Agopian | 3eb38cb | 2012-04-03 22:09:52 -0700 | [diff] [blame] | 242 | // Events handling --------------------------------------------------------- |
| 243 | |
| 244 | enum { |
| 245 | EVENT_VSYNC = HWC_EVENT_VSYNC |
| 246 | }; |
| 247 | |
Mathias Agopian | 81cd5d3 | 2012-10-04 02:34:38 -0700 | [diff] [blame] | 248 | void eventControl(int disp, int event, int enabled); |
Mathias Agopian | 3eb38cb | 2012-04-03 22:09:52 -0700 | [diff] [blame] | 249 | |
Andy McFadden | b0d1dd3 | 2012-09-10 14:08:09 -0700 | [diff] [blame] | 250 | // Query display parameters. Pass in a display index (e.g. |
| 251 | // HWC_DISPLAY_PRIMARY). |
| 252 | nsecs_t getRefreshPeriod(int disp) const; |
| 253 | nsecs_t getRefreshTimestamp(int disp) const; |
Jamie Gennis | 2ec3e07 | 2012-11-11 16:24:33 -0800 | [diff] [blame] | 254 | sp<Fence> getDisplayFence(int disp) const; |
Jesse Hall | db27621 | 2012-09-07 11:20:56 -0700 | [diff] [blame] | 255 | uint32_t getWidth(int disp) const; |
| 256 | uint32_t getHeight(int disp) const; |
Andy McFadden | b0d1dd3 | 2012-09-10 14:08:09 -0700 | [diff] [blame] | 257 | uint32_t getFormat(int disp) const; |
| 258 | float getDpiX(int disp) const; |
| 259 | float getDpiY(int disp) const; |
Mathias Agopian | f5a3392 | 2012-09-19 18:16:22 -0700 | [diff] [blame] | 260 | bool isConnected(int disp) const; |
Mathias Agopian | d3ee231 | 2012-08-02 14:01:42 -0700 | [diff] [blame] | 261 | |
Jesse Hall | 1c569c4 | 2013-04-05 13:44:52 -0700 | [diff] [blame] | 262 | status_t setVirtualDisplayProperties(int32_t id, uint32_t w, uint32_t h, |
| 263 | uint32_t format); |
| 264 | |
Mathias Agopian | 3eb38cb | 2012-04-03 22:09:52 -0700 | [diff] [blame] | 265 | // this class is only used to fake the VSync event on systems that don't |
| 266 | // have it. |
| 267 | class VSyncThread : public Thread { |
| 268 | HWComposer& mHwc; |
| 269 | mutable Mutex mLock; |
| 270 | Condition mCondition; |
| 271 | bool mEnabled; |
| 272 | mutable nsecs_t mNextFakeVSync; |
| 273 | nsecs_t mRefreshPeriod; |
Mathias Agopian | 2965b26 | 2012-04-08 15:13:32 -0700 | [diff] [blame] | 274 | virtual void onFirstRef(); |
| 275 | virtual bool threadLoop(); |
Mathias Agopian | 3eb38cb | 2012-04-03 22:09:52 -0700 | [diff] [blame] | 276 | public: |
Mathias Agopian | 2965b26 | 2012-04-08 15:13:32 -0700 | [diff] [blame] | 277 | VSyncThread(HWComposer& hwc); |
| 278 | void setEnabled(bool enabled); |
Mathias Agopian | 3eb38cb | 2012-04-03 22:09:52 -0700 | [diff] [blame] | 279 | }; |
| 280 | |
| 281 | friend class VSyncThread; |
| 282 | |
| 283 | // for debugging ---------------------------------------------------------- |
Mathias Agopian | 74d211a | 2013-04-22 16:55:35 +0200 | [diff] [blame] | 284 | void dump(String8& out) const; |
Mathias Agopian | 8372785 | 2010-09-23 18:13:21 -0700 | [diff] [blame] | 285 | |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 286 | private: |
Andy McFadden | b0d1dd3 | 2012-09-10 14:08:09 -0700 | [diff] [blame] | 287 | void loadHwcModule(); |
Jesse Hall | ef64b75 | 2013-03-18 11:28:50 -0700 | [diff] [blame] | 288 | int loadFbHalModule(); |
Jesse Hall | b685c54 | 2012-07-31 14:32:56 -0700 | [diff] [blame] | 289 | |
Mathias Agopian | 1e26087 | 2012-08-08 18:35:12 -0700 | [diff] [blame] | 290 | LayerListIterator getLayerIterator(int32_t id, size_t index); |
Mathias Agopian | 31d2843 | 2012-04-03 16:31:39 -0700 | [diff] [blame] | 291 | |
Mathias Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 292 | struct cb_context; |
Mathias Agopian | 31d2843 | 2012-04-03 16:31:39 -0700 | [diff] [blame] | 293 | |
Jesse Hall | bbd164a | 2012-08-21 12:05:09 -0700 | [diff] [blame] | 294 | static void hook_invalidate(const struct hwc_procs* procs); |
Jesse Hall | 1bd20e0 | 2012-08-29 10:47:52 -0700 | [diff] [blame] | 295 | static void hook_vsync(const struct hwc_procs* procs, int disp, |
Jesse Hall | bbd164a | 2012-08-21 12:05:09 -0700 | [diff] [blame] | 296 | int64_t timestamp); |
Jesse Hall | 1bd20e0 | 2012-08-29 10:47:52 -0700 | [diff] [blame] | 297 | static void hook_hotplug(const struct hwc_procs* procs, int disp, |
| 298 | int connected); |
Mathias Agopian | 31d2843 | 2012-04-03 16:31:39 -0700 | [diff] [blame] | 299 | |
Mathias Agopian | 3eb38cb | 2012-04-03 22:09:52 -0700 | [diff] [blame] | 300 | inline void invalidate(); |
Jesse Hall | 1bd20e0 | 2012-08-29 10:47:52 -0700 | [diff] [blame] | 301 | inline void vsync(int disp, int64_t timestamp); |
| 302 | inline void hotplug(int disp, int connected); |
Mathias Agopian | c7d14e2 | 2011-08-01 16:32:21 -0700 | [diff] [blame] | 303 | |
Mathias Agopian | 1604f77 | 2012-09-18 21:54:42 -0700 | [diff] [blame] | 304 | status_t queryDisplayProperties(int disp); |
Mathias Agopian | 1e26087 | 2012-08-08 18:35:12 -0700 | [diff] [blame] | 305 | |
Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 306 | status_t setFramebufferTarget(int32_t id, |
| 307 | const sp<Fence>& acquireFence, const sp<GraphicBuffer>& buf); |
| 308 | |
| 309 | |
Mathias Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 310 | struct DisplayData { |
Jesse Hall | a9a1b00 | 2013-02-27 16:39:25 -0800 | [diff] [blame] | 311 | DisplayData(); |
| 312 | ~DisplayData(); |
Jesse Hall | db27621 | 2012-09-07 11:20:56 -0700 | [diff] [blame] | 313 | uint32_t width; |
| 314 | uint32_t height; |
Andy McFadden | b0d1dd3 | 2012-09-10 14:08:09 -0700 | [diff] [blame] | 315 | uint32_t format; // pixel format from FB hal, for pre-hwc-1.1 |
Mathias Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 316 | float xdpi; |
| 317 | float ydpi; |
| 318 | nsecs_t refresh; |
Mathias Agopian | f5a3392 | 2012-09-19 18:16:22 -0700 | [diff] [blame] | 319 | bool connected; |
Mathias Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 320 | bool hasFbComp; |
| 321 | bool hasOvComp; |
Mathias Agopian | f435863 | 2012-08-22 17:16:19 -0700 | [diff] [blame] | 322 | size_t capacity; |
| 323 | hwc_display_contents_1* list; |
Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 324 | hwc_layer_1* framebufferTarget; |
| 325 | buffer_handle_t fbTargetHandle; |
Jamie Gennis | 2ec3e07 | 2012-11-11 16:24:33 -0800 | [diff] [blame] | 326 | sp<Fence> lastRetireFence; // signals when the last set op retires |
| 327 | sp<Fence> lastDisplayFence; // signals when the last set op takes |
| 328 | // effect on screen |
Jesse Hall | 851cfe8 | 2013-03-20 13:44:00 -0700 | [diff] [blame] | 329 | buffer_handle_t outbufHandle; |
| 330 | sp<Fence> outbufAcquireFence; |
Jamie Gennis | 2ec3e07 | 2012-11-11 16:24:33 -0800 | [diff] [blame] | 331 | |
Mathias Agopian | 81cd5d3 | 2012-10-04 02:34:38 -0700 | [diff] [blame] | 332 | // protected by mEventControlLock |
| 333 | int32_t events; |
Mathias Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 334 | }; |
| 335 | |
Jesse Hall | 5880cc5 | 2012-06-05 23:40:32 -0700 | [diff] [blame] | 336 | sp<SurfaceFlinger> mFlinger; |
Andy McFadden | b0d1dd3 | 2012-09-10 14:08:09 -0700 | [diff] [blame] | 337 | framebuffer_device_t* mFbDev; |
Jesse Hall | 5880cc5 | 2012-06-05 23:40:32 -0700 | [diff] [blame] | 338 | struct hwc_composer_device_1* mHwc; |
Jesse Hall | b685c54 | 2012-07-31 14:32:56 -0700 | [diff] [blame] | 339 | // invariant: mLists[0] != NULL iff mHwc != NULL |
Mathias Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 340 | // mLists[i>0] can be NULL. that display is to be ignored |
Jesse Hall | 9e663de | 2013-08-16 14:28:37 -0700 | [diff] [blame] | 341 | struct hwc_display_contents_1* mLists[MAX_HWC_DISPLAYS]; |
| 342 | DisplayData mDisplayData[MAX_HWC_DISPLAYS]; |
Jesse Hall | 8f971ff | 2012-08-22 11:50:00 -0700 | [diff] [blame] | 343 | size_t mNumDisplays; |
Mathias Agopian | 1e26087 | 2012-08-08 18:35:12 -0700 | [diff] [blame] | 344 | |
Jesse Hall | 5880cc5 | 2012-06-05 23:40:32 -0700 | [diff] [blame] | 345 | cb_context* mCBContext; |
| 346 | EventHandler& mEventHandler; |
Mathias Agopian | bef42c5 | 2013-08-21 17:45:46 -0700 | [diff] [blame] | 347 | size_t mVSyncCounts[HWC_NUM_PHYSICAL_DISPLAY_TYPES]; |
Jesse Hall | 5880cc5 | 2012-06-05 23:40:32 -0700 | [diff] [blame] | 348 | sp<VSyncThread> mVSyncThread; |
| 349 | bool mDebugForceFakeVSync; |
Mathias Agopian | f435863 | 2012-08-22 17:16:19 -0700 | [diff] [blame] | 350 | BitSet32 mAllocatedDisplayIDs; |
Mathias Agopian | d3ee231 | 2012-08-02 14:01:42 -0700 | [diff] [blame] | 351 | |
| 352 | // protected by mLock |
| 353 | mutable Mutex mLock; |
Mathias Agopian | bef42c5 | 2013-08-21 17:45:46 -0700 | [diff] [blame] | 354 | mutable nsecs_t mLastHwVSync[HWC_NUM_PHYSICAL_DISPLAY_TYPES]; |
Mathias Agopian | 81cd5d3 | 2012-10-04 02:34:38 -0700 | [diff] [blame] | 355 | |
| 356 | // thread-safe |
| 357 | mutable Mutex mEventControlLock; |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 358 | }; |
| 359 | |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 360 | // --------------------------------------------------------------------------- |
| 361 | }; // namespace android |
| 362 | |
| 363 | #endif // ANDROID_SF_HWCOMPOSER_H |