blob: 0a5c47e9e1000edc64c637e2f5f7bd1f056947df [file] [log] [blame]
Andy Qiu8a427142013-04-05 17:41:58 -07001/*
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 Singhi196e5bd2013-04-17 18:26:37 -070033#include "IFrameServer.h"
Andy Qiu8a427142013-04-05 17:41:58 -070034
35namespace android {
36namespace intel {
37
38class Hwcomposer;
39class DisplayPlaneManager;
Robert Crabtree2e984ef2013-05-07 14:27:47 -070040class IVideoPayloadManager;
Andy Qiu8a427142013-04-05 17:41:58 -070041
Ashish Singhi196e5bd2013-04-17 18:26:37 -070042class VirtualDevice : public IDisplayDevice, public BnFrameServer {
Ashish Singhi77b747d2013-04-26 14:30:05 -070043protected:
Robert Crabtree2e984ef2013-05-07 14:27:47 -070044 struct CachedBuffer : public android::RefBase {
45 CachedBuffer(BufferManager *mgr, buffer_handle_t handle);
46 ~CachedBuffer();
47 BufferManager *manager;
Robert Crabtree2e984ef2013-05-07 14:27:47 -070048 BufferMapper *mapper;
49 };
Ashish Singhi77b747d2013-04-26 14:30:05 -070050 struct Configuration {
51 sp<IFrameTypeChangeListener> typeChangeListener;
52 sp<IFrameListener> frameListener;
53 FrameProcessingPolicy policy;
54 bool extendedModeEnabled;
55 bool forceNotify;
56 };
57 Mutex mConfigLock;
58 Configuration mCurrentConfig;
59 Configuration mNextConfig;
60
61 uint32_t mExtLastKhandle;
62 int64_t mExtLastTimestamp;
63
64 Mutex mListenerLock;
65 FrameInfo mLastFrameInfo;
Robert Crabtree2e984ef2013-05-07 14:27:47 -070066
67 android::KeyedVector<buffer_handle_t, android::sp<CachedBuffer> > mDisplayBufferCache;
68 android::Mutex mHeldBuffersLock;
69 android::KeyedVector<uint32_t, android::sp<CachedBuffer> > mHeldBuffers;
70
71private:
72 android::sp<CachedBuffer> getDisplayBuffer(buffer_handle_t handle);
73
Andy Qiu8a427142013-04-05 17:41:58 -070074public:
75 VirtualDevice(Hwcomposer& hwc, DisplayPlaneManager& dpm);
76 virtual ~VirtualDevice();
77
78public:
79 virtual bool prePrepare(hwc_display_contents_1_t *display);
80 virtual bool prepare(hwc_display_contents_1_t *display);
81 virtual bool commit(hwc_display_contents_1_t *display,
Andy Qiu4b834ce2013-04-09 18:23:20 -070082 IDisplayContext *context);
Andy Qiu8a427142013-04-05 17:41:58 -070083
Andy Qiueb726af2013-05-31 11:51:49 +080084 virtual bool vsyncControl(bool enabled);
85 virtual bool blank(bool blank);
Andy Qiu0131f122013-07-19 14:51:20 -070086 virtual bool getDisplaySize(int *width, int *height);
Andy Qiu8a427142013-04-05 17:41:58 -070087 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 jine2ad4c02013-05-28 13:47:51 -070094 virtual void deinitialize();
Andy Qiu8a427142013-04-05 17:41:58 -070095 virtual bool isConnected() const;
96 virtual const char* getName() const;
97 virtual int getType() const;
98 virtual void dump(Dump& d);
99
Ashish Singhi196e5bd2013-04-17 18:26:37 -0700100 // IFrameServer methods
Ashish Singhi77b747d2013-04-26 14:30:05 -0700101 virtual android::status_t start(sp<IFrameTypeChangeListener> frameTypeChangeListener, bool disableExtVideoMode);
Ashish Singhi196e5bd2013-04-17 18:26:37 -0700102 virtual android::status_t stop(bool isConnected);
103 virtual android::status_t notifyBufferReturned(int index);
Ashish Singhi77b747d2013-04-26 14:30:05 -0700104 virtual android::status_t setResolution(const FrameProcessingPolicy& policy, android::sp<IFrameListener> listener);
Andy Qiu8a427142013-04-05 17:41:58 -0700105protected:
Robert Crabtree2e984ef2013-05-07 14:27:47 -0700106 virtual IVideoPayloadManager* createVideoPayloadManager() = 0;
Andy Qiu8a427142013-04-05 17:41:58 -0700107
108protected:
109 bool mInitialized;
110 Hwcomposer& mHwc;
111 DisplayPlaneManager& mDisplayPlaneManager;
Robert Crabtree2e984ef2013-05-07 14:27:47 -0700112 IVideoPayloadManager *mPayloadManager;
Andy Qiu8a427142013-04-05 17:41:58 -0700113};
114
115}
116}
117
118#endif /* VIRTUAL_DEVICE_H */