| Andy Qiu | 8a42714 | 2013-04-05 17:41:58 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2012 Intel Corporation |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 6 | * copy of this software and associated documentation files (the "Software"), |
| 7 | * to deal in the Software without restriction, including without limitation |
| 8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 9 | * and/or sell copies of the Software, and to permit persons to whom the |
| 10 | * Software is furnished to do so, subject to the following conditions: |
| 11 | * |
| 12 | * The above copyright notice and this permission notice (including the next |
| 13 | * paragraph) shall be included in all copies or substantial portions of the |
| 14 | * Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 22 | * IN THE SOFTWARE. |
| 23 | * |
| 24 | * Authors: |
| 25 | * Jackie Li <yaodong.li@intel.com> |
| 26 | * |
| 27 | */ |
| 28 | #ifndef VIRTUAL_DEVICE_H |
| 29 | #define VIRTUAL_DEVICE_H |
| 30 | |
| 31 | |
| 32 | #include <IDisplayDevice.h> |
| Ashish Singhi | 196e5bd | 2013-04-17 18:26:37 -0700 | [diff] [blame] | 33 | #include "IFrameServer.h" |
| Andy Qiu | 8a42714 | 2013-04-05 17:41:58 -0700 | [diff] [blame] | 34 | |
| 35 | namespace android { |
| 36 | namespace intel { |
| 37 | |
| 38 | class Hwcomposer; |
| 39 | class DisplayPlaneManager; |
| Robert Crabtree | 2e984ef | 2013-05-07 14:27:47 -0700 | [diff] [blame] | 40 | class IVideoPayloadManager; |
| Andy Qiu | 8a42714 | 2013-04-05 17:41:58 -0700 | [diff] [blame] | 41 | |
| Ashish Singhi | 196e5bd | 2013-04-17 18:26:37 -0700 | [diff] [blame] | 42 | class VirtualDevice : public IDisplayDevice, public BnFrameServer { |
| Ashish Singhi | 77b747d | 2013-04-26 14:30:05 -0700 | [diff] [blame] | 43 | protected: |
| Robert Crabtree | 2e984ef | 2013-05-07 14:27:47 -0700 | [diff] [blame] | 44 | struct CachedBuffer : public android::RefBase { |
| 45 | CachedBuffer(BufferManager *mgr, buffer_handle_t handle); |
| 46 | ~CachedBuffer(); |
| 47 | BufferManager *manager; |
| 48 | DataBuffer *buffer; |
| 49 | BufferMapper *mapper; |
| 50 | }; |
| Ashish Singhi | 77b747d | 2013-04-26 14:30:05 -0700 | [diff] [blame] | 51 | struct Configuration { |
| 52 | sp<IFrameTypeChangeListener> typeChangeListener; |
| 53 | sp<IFrameListener> frameListener; |
| 54 | FrameProcessingPolicy policy; |
| 55 | bool extendedModeEnabled; |
| 56 | bool forceNotify; |
| 57 | }; |
| 58 | Mutex mConfigLock; |
| 59 | Configuration mCurrentConfig; |
| 60 | Configuration mNextConfig; |
| 61 | |
| 62 | uint32_t mExtLastKhandle; |
| 63 | int64_t mExtLastTimestamp; |
| 64 | |
| 65 | Mutex mListenerLock; |
| 66 | FrameInfo mLastFrameInfo; |
| Robert Crabtree | 2e984ef | 2013-05-07 14:27:47 -0700 | [diff] [blame] | 67 | |
| 68 | android::KeyedVector<buffer_handle_t, android::sp<CachedBuffer> > mDisplayBufferCache; |
| 69 | android::Mutex mHeldBuffersLock; |
| 70 | android::KeyedVector<uint32_t, android::sp<CachedBuffer> > mHeldBuffers; |
| 71 | |
| 72 | private: |
| 73 | android::sp<CachedBuffer> getDisplayBuffer(buffer_handle_t handle); |
| 74 | |
| Andy Qiu | 8a42714 | 2013-04-05 17:41:58 -0700 | [diff] [blame] | 75 | public: |
| 76 | VirtualDevice(Hwcomposer& hwc, DisplayPlaneManager& dpm); |
| 77 | virtual ~VirtualDevice(); |
| 78 | |
| 79 | public: |
| 80 | virtual bool prePrepare(hwc_display_contents_1_t *display); |
| 81 | virtual bool prepare(hwc_display_contents_1_t *display); |
| 82 | virtual bool commit(hwc_display_contents_1_t *display, |
| Andy Qiu | 4b834ce | 2013-04-09 18:23:20 -0700 | [diff] [blame] | 83 | IDisplayContext *context); |
| Andy Qiu | 8a42714 | 2013-04-05 17:41:58 -0700 | [diff] [blame] | 84 | |
| 85 | virtual bool vsyncControl(int enabled); |
| 86 | virtual bool blank(int blank); |
| 87 | virtual bool getDisplayConfigs(uint32_t *configs, |
| 88 | size_t *numConfigs); |
| 89 | virtual bool getDisplayAttributes(uint32_t config, |
| 90 | const uint32_t *attributes, |
| 91 | int32_t *values); |
| 92 | virtual bool compositionComplete(); |
| 93 | virtual bool initialize(); |
| fu jin | e2ad4c0 | 2013-05-28 13:47:51 -0700 | [diff] [blame] | 94 | virtual void deinitialize(); |
| Andy Qiu | 8a42714 | 2013-04-05 17:41:58 -0700 | [diff] [blame] | 95 | virtual bool isConnected() const; |
| 96 | virtual const char* getName() const; |
| 97 | virtual int getType() const; |
| 98 | virtual void dump(Dump& d); |
| 99 | |
| Ashish Singhi | 196e5bd | 2013-04-17 18:26:37 -0700 | [diff] [blame] | 100 | // IFrameServer methods |
| Ashish Singhi | 77b747d | 2013-04-26 14:30:05 -0700 | [diff] [blame] | 101 | virtual android::status_t start(sp<IFrameTypeChangeListener> frameTypeChangeListener, bool disableExtVideoMode); |
| Ashish Singhi | 196e5bd | 2013-04-17 18:26:37 -0700 | [diff] [blame] | 102 | virtual android::status_t stop(bool isConnected); |
| 103 | virtual android::status_t notifyBufferReturned(int index); |
| Ashish Singhi | 77b747d | 2013-04-26 14:30:05 -0700 | [diff] [blame] | 104 | virtual android::status_t setResolution(const FrameProcessingPolicy& policy, android::sp<IFrameListener> listener); |
| Andy Qiu | 8a42714 | 2013-04-05 17:41:58 -0700 | [diff] [blame] | 105 | protected: |
| Robert Crabtree | 2e984ef | 2013-05-07 14:27:47 -0700 | [diff] [blame] | 106 | virtual IVideoPayloadManager* createVideoPayloadManager() = 0; |
| Andy Qiu | 8a42714 | 2013-04-05 17:41:58 -0700 | [diff] [blame] | 107 | |
| 108 | protected: |
| 109 | bool mInitialized; |
| 110 | Hwcomposer& mHwc; |
| 111 | DisplayPlaneManager& mDisplayPlaneManager; |
| Robert Crabtree | 2e984ef | 2013-05-07 14:27:47 -0700 | [diff] [blame] | 112 | IVideoPayloadManager *mPayloadManager; |
| Andy Qiu | 8a42714 | 2013-04-05 17:41:58 -0700 | [diff] [blame] | 113 | }; |
| 114 | |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | #endif /* VIRTUAL_DEVICE_H */ |