Naseer Ahmed | 58780b9 | 2013-07-29 17:41:40 -0400 | [diff] [blame] | 1 | /* |
Zohaib Alam | 1bb6561 | 2013-09-28 03:38:20 -0400 | [diff] [blame] | 2 | * Copyright (c) 2013-2014 The Linux Foundation. All rights reserved. |
Naseer Ahmed | 58780b9 | 2013-07-29 17:41:40 -0400 | [diff] [blame] | 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions are |
| 6 | * met: |
| 7 | * * Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * * Redistributions in binary form must reproduce the above |
| 10 | * copyright notice, this list of conditions and the following |
| 11 | * disclaimer in the documentation and/or other materials provided |
| 12 | * with the distribution. |
| 13 | * * Neither the name of The Linux Foundation. nor the names of its |
| 14 | * contributors may be used to endorse or promote products derived |
| 15 | * from this software without specific prior written permission. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 24 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 27 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | */ |
| 29 | |
| 30 | #ifndef HWC_VPU_H |
| 31 | #define HWC_VPU_H |
| 32 | |
| 33 | #include <sys/types.h> |
Zohaib Alam | 1bb6561 | 2013-09-28 03:38:20 -0400 | [diff] [blame] | 34 | #include "hwc_utils.h" |
| 35 | |
| 36 | #define MAX_PIPES_PER_LAYER 2 |
Naseer Ahmed | 58780b9 | 2013-07-29 17:41:40 -0400 | [diff] [blame] | 37 | |
| 38 | //Forward declarations |
| 39 | struct hwc_display_contents_1; |
| 40 | typedef struct hwc_display_contents_1 hwc_display_contents_1_t; |
Zohaib Alam | 1bb6561 | 2013-09-28 03:38:20 -0400 | [diff] [blame] | 41 | struct hwc_layer_1; |
| 42 | typedef struct hwc_layer_1 hwc_layer_1_t; |
Naseer Ahmed | 58780b9 | 2013-07-29 17:41:40 -0400 | [diff] [blame] | 43 | struct hwc_context_t; |
Zohaib Alam | 1bb6561 | 2013-09-28 03:38:20 -0400 | [diff] [blame] | 44 | |
Naseer Ahmed | 58780b9 | 2013-07-29 17:41:40 -0400 | [diff] [blame] | 45 | namespace vpu { |
| 46 | class VPU; |
Zohaib Alam | 1bb6561 | 2013-09-28 03:38:20 -0400 | [diff] [blame] | 47 | struct LayerList; |
Naseer Ahmed | 58780b9 | 2013-07-29 17:41:40 -0400 | [diff] [blame] | 48 | }; |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 49 | namespace android { |
| 50 | class Parcel; |
| 51 | }; |
Naseer Ahmed | 58780b9 | 2013-07-29 17:41:40 -0400 | [diff] [blame] | 52 | |
| 53 | namespace qhwc { |
| 54 | |
| 55 | class VPUClient { |
| 56 | public: |
Zohaib Alam | 1bb6561 | 2013-09-28 03:38:20 -0400 | [diff] [blame] | 57 | VPUClient(hwc_context_t *ctx); |
Naseer Ahmed | 58780b9 | 2013-07-29 17:41:40 -0400 | [diff] [blame] | 58 | |
| 59 | ~VPUClient(); |
| 60 | |
Zohaib Alam | 1bb6561 | 2013-09-28 03:38:20 -0400 | [diff] [blame] | 61 | int setupVpuSession(hwc_context_t *ctx, int display, |
| 62 | hwc_display_contents_1_t* list); |
| 63 | int prepare(hwc_context_t *ctx, int display, |
| 64 | hwc_display_contents_1_t* list); |
| 65 | int predraw(hwc_context_t *ctx, int display, |
| 66 | hwc_display_contents_1_t* list); |
| 67 | int draw(hwc_context_t *ctx, int display, |
| 68 | hwc_display_contents_1_t* list); |
Naseer Ahmed | 4957c52 | 2013-11-12 18:07:15 -0500 | [diff] [blame] | 69 | int processCommand(uint32_t command, |
Zohaib Alam | 1bb6561 | 2013-09-28 03:38:20 -0400 | [diff] [blame] | 70 | const android::Parcel* inParcel, android::Parcel* outParcel); |
| 71 | int getLayerFormat(int dpy, hwc_layer_1_t *layer); |
| 72 | int getWidth(int dpy, hwc_layer_1_t *layer); |
| 73 | int getHeight(int dpy, hwc_layer_1_t *layer); |
| 74 | bool supportedVPULayer(int dpy, hwc_layer_1_t *layer); |
Naseer Ahmed | 58780b9 | 2013-07-29 17:41:40 -0400 | [diff] [blame] | 75 | |
| 76 | private: |
| 77 | vpu::VPU *mVPU; |
| 78 | void* mVPULib; |
| 79 | |
Zohaib Alam | 1bb6561 | 2013-09-28 03:38:20 -0400 | [diff] [blame] | 80 | /* VpuLayerProp struct: |
| 81 | * This struct corresponds to only one layer |
| 82 | * pipeCount: number of pipes required for a layer |
| 83 | * pipeID[]: pipe ids corresponding to the layer |
| 84 | */ |
| 85 | struct VpuLayerProp { |
| 86 | int format; |
| 87 | int width; |
| 88 | int height; |
| 89 | int pipeCount; |
| 90 | bool vpuLayer; |
| 91 | bool firstBuffer; |
| 92 | hwc_frect_t sourceCropf; |
| 93 | hwc_layer_1_t *layer; |
| 94 | int pipeID[MAX_PIPES_PER_LAYER]; |
| 95 | int dest[MAX_PIPES_PER_LAYER]; |
| 96 | }; |
| 97 | int mNumVpuLayers; /* total num of vpu supported layers */ |
| 98 | int mGpuFallback; /* all layers are not supported by vpu */ |
| 99 | |
| 100 | VpuLayerProp mProp[HWC_NUM_DISPLAY_TYPES][MAX_NUM_APP_LAYERS]; |
| 101 | int mDebugLogs; |
| 102 | private_handle_t *mHnd[HWC_NUM_DISPLAY_TYPES][MAX_NUM_APP_LAYERS]; |
| 103 | vpu::LayerList *vList[HWC_NUM_DISPLAY_TYPES]; |
| 104 | |
| 105 | /* Private debug functions */ |
| 106 | int32_t isDebug() { return (mDebugLogs >= 1); } |
| 107 | int32_t isDebug2() { return (mDebugLogs >= 2); } |
| 108 | |
| 109 | /* Private Get/Set functions */ |
| 110 | int getLayerIdx(int dpy, hwc_layer_1_t *layer); |
| 111 | void getPipeId(VpuLayerProp* prop, int &pipe); |
| 112 | void getPipeId(VpuLayerProp* prop, int &lPipe, int &rPipe); |
| 113 | int getDest(VpuLayerProp* prop, int pipenum); |
| 114 | void setPipeCount(VpuLayerProp* prop, int count); |
| 115 | void setPipeId(VpuLayerProp* prop, int lPipeId, int rPipeId); |
| 116 | void setPipeId(VpuLayerProp* prop, int pipeId); |
| 117 | void setDest(VpuLayerProp* prop, int lDest, int rDest); |
| 118 | void setDest(VpuLayerProp* prop, int dest); |
| 119 | |
| 120 | /* Private implementations */ |
| 121 | bool supportedVPULayer(VpuLayerProp* prop); |
| 122 | bool allocResLayerPipes(hwc_context_t* ctx, int dpy, |
| 123 | hwc_display_contents_1_t* list); |
| 124 | bool allocLayerPipes(hwc_context_t* ctx, int dpy, |
| 125 | hwc_display_contents_1_t* list); |
| 126 | bool allocResLayerPipesSplit(hwc_context_t* ctx, int dpy, |
| 127 | hwc_display_contents_1_t* list); |
| 128 | bool allocLayerPipesSplit(hwc_context_t* ctx, int dpy, |
| 129 | hwc_display_contents_1_t* list); |
| 130 | bool configureLayers(hwc_context_t* ctx, int dpy, |
| 131 | hwc_display_contents_1_t* list); |
| 132 | bool configureLayersSplit(hwc_context_t* ctx, int dpy, |
| 133 | hwc_display_contents_1_t* list); |
| 134 | void setMDPCompLayerFlags(hwc_context_t *ctx, int dpy, |
| 135 | hwc_display_contents_1_t* list); |
| 136 | bool drawDummyLayers(hwc_context_t* ctx, int dpy, |
| 137 | hwc_display_contents_1_t* list); |
| 138 | bool queueHandle(hwc_context_t* ctx, VpuLayerProp* prop, |
| 139 | private_handle_t* hnd); |
| 140 | bool queueHandleSplit(hwc_context_t* ctx, VpuLayerProp* prop, |
| 141 | private_handle_t* hnd); |
Naseer Ahmed | 58780b9 | 2013-07-29 17:41:40 -0400 | [diff] [blame] | 142 | }; // class VPU |
| 143 | }; // namespace qhwc |
| 144 | #endif /* end of include guard: HWC_VPU_H */ |