Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 1 | /* |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame^] | 2 | * Copyright (C) 2012-2013, The Linux Foundation. All rights reserved. |
| 3 | * |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 4 | * Not a Contribution, Apache license notifications and license are retained |
| 5 | * for attribution purposes only. |
| 6 | * |
| 7 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | * you may not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
| 10 | * |
| 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | * |
| 13 | * Unless required by applicable law or agreed to in writing, software |
| 14 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | * See the License for the specific language governing permissions and |
| 17 | * limitations under the License. |
| 18 | */ |
| 19 | |
| 20 | #ifndef HWC_MDP_COMP |
| 21 | #define HWC_MDP_COMP |
| 22 | |
| 23 | #include <hwc_utils.h> |
| 24 | #include <idle_invalidator.h> |
| 25 | #include <cutils/properties.h> |
| 26 | #include <overlay.h> |
| 27 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 28 | #define DEFAULT_IDLE_TIME 2000 |
Sushil Chauhan | 69f2bb2 | 2013-02-13 10:50:47 -0800 | [diff] [blame] | 29 | #define MAX_PIPES_PER_MIXER 4 |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 30 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 31 | namespace qhwc { |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 32 | namespace ovutils = overlay::utils; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 33 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame^] | 34 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 35 | class MDPComp { |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 36 | public: |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame^] | 37 | virtual ~MDPComp(){}; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 38 | /*sets up mdp comp for the current frame */ |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame^] | 39 | bool prepare(hwc_context_t *ctx, hwc_display_contents_1_t* list); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 40 | /* draw */ |
| 41 | virtual bool draw(hwc_context_t *ctx, hwc_display_contents_1_t *list) = 0; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame^] | 42 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 43 | void dump(android::String8& buf); |
| 44 | bool isUsed() { return (mState == MDPCOMP_ON); }; |
| 45 | |
| 46 | static MDPComp* getObject(const int& width); |
| 47 | /* Handler to invoke frame redraw on Idle Timer expiry */ |
| 48 | static void timeout_handler(void *udata); |
| 49 | static bool init(hwc_context_t *ctx); |
| 50 | |
| 51 | protected: |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 52 | enum eState { |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 53 | MDPCOMP_ON = 0, |
| 54 | MDPCOMP_OFF, |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 55 | }; |
| 56 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 57 | enum ePipeType { |
| 58 | MDPCOMP_OV_RGB = ovutils::OV_MDP_PIPE_RGB, |
| 59 | MDPCOMP_OV_VG = ovutils::OV_MDP_PIPE_VG, |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame^] | 60 | MDPCOMP_OV_DMA = ovutils::OV_MDP_PIPE_DMA, |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 61 | MDPCOMP_OV_ANY, |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 62 | }; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame^] | 63 | struct MdpPipeInfo { |
| 64 | int zOrder; |
| 65 | virtual ~MdpPipeInfo(){}; |
| 66 | }; |
| 67 | struct PipeLayerPair { |
| 68 | MdpPipeInfo *pipeInfo; |
| 69 | native_handle_t* handle; |
| 70 | }; |
| 71 | |
| 72 | /* introduced for mixed mode implementation */ |
| 73 | struct FrameInfo { |
| 74 | int count; |
| 75 | struct PipeLayerPair* pipeLayer; |
| 76 | }; |
| 77 | |
| 78 | /* calculates pipes needed for the panel */ |
| 79 | virtual int pipesNeeded(hwc_context_t *ctx, |
| 80 | hwc_display_contents_1_t* list) = 0; |
| 81 | /* allocates pipe from pipe book */ |
| 82 | virtual bool allocLayerPipes(hwc_context_t *ctx, |
| 83 | hwc_display_contents_1_t* list,FrameInfo& current_frame) = 0; |
| 84 | /* configures MPD pipes */ |
| 85 | virtual int configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
| 86 | MdpPipeInfo* mdp_info) = 0; |
| 87 | /* Is rotation supported */ |
| 88 | virtual bool canRotate(){ return true; }; |
| 89 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 90 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 91 | /* set/reset flags for MDPComp */ |
| 92 | void setMDPCompLayerFlags(hwc_context_t *ctx, |
| 93 | hwc_display_contents_1_t* list); |
| 94 | void unsetMDPCompLayerFlags(hwc_context_t* ctx, |
| 95 | hwc_display_contents_1_t* list); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 96 | /* get/set states */ |
| 97 | eState getState() { return mState; }; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame^] | 98 | /* reset state */ |
| 99 | void reset( hwc_context_t *ctx, hwc_display_contents_1_t* list ); |
| 100 | /* configure MDP flags for video buffers */ |
| 101 | void setVidInfo(hwc_layer_1_t *layer, ovutils::eMdpFlags &mdpFlags); |
| 102 | /* allocate MDP pipes from overlay */ |
| 103 | ovutils::eDest getMdpPipe(hwc_context_t *ctx, ePipeType type); |
| 104 | /* checks for conditions where mdpcomp is not possible */ |
| 105 | bool isDoable(hwc_context_t *ctx, hwc_display_contents_1_t* list); |
| 106 | /* sets up MDP comp for current frame */ |
| 107 | bool setup(hwc_context_t* ctx, hwc_display_contents_1_t* list); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 108 | /* set up Border fill as Base pipe */ |
| 109 | static bool setupBasePipe(hwc_context_t*); |
| 110 | /* Is debug enabled */ |
| 111 | static bool isDebug() { return sDebugLogs ? true : false; }; |
| 112 | /* Is feature enabled */ |
| 113 | static bool isEnabled() { return sEnabled; }; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame^] | 114 | /* checks for mdp comp width limitation */ |
| 115 | bool isWidthValid(hwc_context_t *ctx, hwc_layer_1_t *layer); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 116 | |
| 117 | eState mState; |
| 118 | |
| 119 | static bool sEnabled; |
| 120 | static bool sDebugLogs; |
| 121 | static bool sIdleFallBack; |
| 122 | static IdleInvalidator *idleInvalidator; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame^] | 123 | struct FrameInfo mCurrentFrame; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 124 | }; |
| 125 | |
| 126 | class MDPCompLowRes : public MDPComp { |
| 127 | public: |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame^] | 128 | virtual ~MDPCompLowRes(){}; |
| 129 | virtual bool draw(hwc_context_t *ctx, hwc_display_contents_1_t *list); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 130 | |
| 131 | private: |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame^] | 132 | struct MdpPipeInfoLowRes : public MdpPipeInfo { |
| 133 | ovutils::eDest index; |
| 134 | virtual ~MdpPipeInfoLowRes() {}; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 135 | }; |
| 136 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 137 | /* configure's overlay pipes for the frame */ |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame^] | 138 | virtual int configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
| 139 | MdpPipeInfo* mdp_info); |
| 140 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 141 | /* allocates pipes to selected candidates */ |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame^] | 142 | virtual bool allocLayerPipes(hwc_context_t *ctx, |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 143 | hwc_display_contents_1_t* list, |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 144 | FrameInfo& current_frame); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 145 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame^] | 146 | virtual int pipesNeeded(hwc_context_t *ctx, |
| 147 | hwc_display_contents_1_t* list); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 148 | }; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 149 | |
| 150 | class MDPCompHighRes : public MDPComp { |
| 151 | public: |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame^] | 152 | virtual ~MDPCompHighRes(){}; |
| 153 | virtual bool draw(hwc_context_t *ctx, hwc_display_contents_1_t *list); |
| 154 | private: |
| 155 | struct MdpPipeInfoHighRes : public MdpPipeInfo { |
| 156 | ovutils::eDest lIndex; |
| 157 | ovutils::eDest rIndex; |
| 158 | virtual ~MdpPipeInfoHighRes() {}; |
| 159 | }; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 160 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame^] | 161 | bool acquireMDPPipes(hwc_context_t *ctx, hwc_layer_1_t* layer, |
| 162 | MdpPipeInfoHighRes& pipe_info, ePipeType type); |
| 163 | |
| 164 | /* configure's overlay pipes for the frame */ |
| 165 | virtual int configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
| 166 | MdpPipeInfo* mdp_info); |
| 167 | |
| 168 | /* allocates pipes to selected candidates */ |
| 169 | virtual bool allocLayerPipes(hwc_context_t *ctx, |
| 170 | hwc_display_contents_1_t* list, |
| 171 | FrameInfo& current_frame); |
| 172 | |
| 173 | virtual int pipesNeeded(hwc_context_t *ctx, hwc_display_contents_1_t* list); |
| 174 | virtual bool canRotate(){ return false; }; |
| 175 | }; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 176 | }; //namespace |
| 177 | #endif |