1 /* 2 * Copyright (C) 2010 The Android Open Source Project 3 * Copyright (C) 2012-2014, The Linux Foundation. All rights reserved. 4 * 5 * Not a Contribution, Apache license notifications and license are retained 6 * for attribution purposes only. 7 * 8 * Licensed under the Apache License, Version 2.0 (the "License"); 9 * you may not use this file except in compliance with the License. 10 * You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, software 15 * distributed under the License is distributed on an "AS IS" BASIS, 16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 * See the License for the specific language governing permissions and 18 * limitations under the License. 19 */ 20 21 #ifndef HWC_VIRTUAL 22 #define HWC_VIRTUAL 23 24 #include <hwc_utils.h> 25 #include <virtual.h> 26 27 namespace qhwc { 28 namespace ovutils = overlay::utils; 29 30 // Base and abstract class for VDS and V4L2 wfd design. 31 class HWCVirtualBase { 32 public: HWCVirtualBase()33 explicit HWCVirtualBase(){}; ~HWCVirtualBase()34 virtual ~HWCVirtualBase(){}; 35 // instantiates and returns the pointer to VDS or V4L2 object. 36 static HWCVirtualBase* getObject(bool isVDSEnabled); 37 virtual int prepare(hwc_composer_device_1 *dev, 38 hwc_display_contents_1_t* list) = 0; 39 virtual int set(hwc_context_t *ctx, hwc_display_contents_1_t *list) = 0; 40 virtual void init(hwc_context_t *ctx) = 0; 41 virtual void destroy(hwc_context_t *ctx, size_t numDisplays, 42 hwc_display_contents_1_t** displays) = 0; 43 virtual void pause(hwc_context_t* ctx, int dpy) = 0; 44 virtual void resume(hwc_context_t* ctx, int dpy) = 0; 45 }; 46 47 class HWCVirtualVDS : public HWCVirtualBase { 48 public: 49 explicit HWCVirtualVDS(); ~HWCVirtualVDS()50 virtual ~HWCVirtualVDS(){}; 51 // Chooses composition type and configures pipe for each layer in virtual 52 // display list 53 virtual int prepare(hwc_composer_device_1 *dev, 54 hwc_display_contents_1_t* list); 55 // Queues the buffer for each layer in virtual display list and call display 56 // commit. 57 virtual int set(hwc_context_t *ctx, hwc_display_contents_1_t *list); 58 // instantiates mdpcomp, copybit and fbupdate objects and initialize those 59 // objects for virtual display during virtual display connect. 60 virtual void init(hwc_context_t *ctx); 61 // Destroys mdpcomp, copybit and fbupdate objects and for virtual display 62 // during virtual display disconnect. 63 virtual void destroy(hwc_context_t *ctx, size_t numDisplays, 64 hwc_display_contents_1_t** displays); 65 virtual void pause(hwc_context_t* ctx, int dpy); 66 virtual void resume(hwc_context_t* ctx, int dpy); 67 private: 68 // If WFD is enabled through VDS solution 69 // we can dump the frame buffer and WB 70 // output buffer by setting the property 71 // debug.hwc.enable_vds_dump 72 bool mVDSDumpEnabled; 73 }; 74 75 class HWCVirtualV4L2 : public HWCVirtualBase { 76 public: HWCVirtualV4L2()77 explicit HWCVirtualV4L2(){}; ~HWCVirtualV4L2()78 virtual ~HWCVirtualV4L2(){}; 79 // Chooses composition type and configures pipe for each layer in virtual 80 // display list 81 virtual int prepare(hwc_composer_device_1 *dev, 82 hwc_display_contents_1_t* list); 83 // Queues the buffer for each layer in virtual display list and call 84 // display commit. 85 virtual int set(hwc_context_t *ctx, hwc_display_contents_1_t *list); 86 // instantiates mdpcomp, copybit and fbupdate objects and initialize those 87 // objects for virtual display during virtual display connect. This function 88 // is no-op for V4L2 design init(hwc_context_t *)89 virtual void init(hwc_context_t *) {}; 90 // Destroys mdpcomp, copybit and fbupdate objects and for virtual display 91 // during virtual display disconnect. This function is no-op for V4L2 design destroy(hwc_context_t *,size_t,hwc_display_contents_1_t **)92 virtual void destroy(hwc_context_t *, size_t , 93 hwc_display_contents_1_t** ) {}; 94 virtual void pause(hwc_context_t* ctx, int dpy); 95 virtual void resume(hwc_context_t* ctx, int dpy); 96 }; 97 98 }; //namespace 99 #endif 100