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 | |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 31 | namespace overlay { |
| 32 | class Rotator; |
| 33 | }; |
| 34 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 35 | namespace qhwc { |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 36 | namespace ovutils = overlay::utils; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 37 | |
| 38 | class MDPComp { |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 39 | public: |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 40 | virtual ~MDPComp(){}; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 41 | /*sets up mdp comp for the current frame */ |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 42 | bool prepare(hwc_context_t *ctx, hwc_display_contents_1_t* list); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 43 | /* draw */ |
| 44 | 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] | 45 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 46 | void dump(android::String8& buf); |
| 47 | bool isUsed() { return (mState == MDPCOMP_ON); }; |
| 48 | |
| 49 | static MDPComp* getObject(const int& width); |
| 50 | /* Handler to invoke frame redraw on Idle Timer expiry */ |
| 51 | static void timeout_handler(void *udata); |
| 52 | static bool init(hwc_context_t *ctx); |
| 53 | |
| 54 | protected: |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 55 | enum eState { |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 56 | MDPCOMP_ON = 0, |
| 57 | MDPCOMP_OFF, |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 58 | }; |
| 59 | |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 60 | enum ePipeType { |
| 61 | MDPCOMP_OV_RGB = ovutils::OV_MDP_PIPE_RGB, |
| 62 | MDPCOMP_OV_VG = ovutils::OV_MDP_PIPE_VG, |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 63 | MDPCOMP_OV_DMA = ovutils::OV_MDP_PIPE_DMA, |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 64 | MDPCOMP_OV_ANY, |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 65 | }; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 66 | struct MdpPipeInfo { |
| 67 | int zOrder; |
| 68 | virtual ~MdpPipeInfo(){}; |
| 69 | }; |
| 70 | struct PipeLayerPair { |
| 71 | MdpPipeInfo *pipeInfo; |
| 72 | native_handle_t* handle; |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 73 | overlay::Rotator* rot; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | /* introduced for mixed mode implementation */ |
| 77 | struct FrameInfo { |
| 78 | int count; |
| 79 | struct PipeLayerPair* pipeLayer; |
| 80 | }; |
| 81 | |
| 82 | /* calculates pipes needed for the panel */ |
| 83 | virtual int pipesNeeded(hwc_context_t *ctx, |
| 84 | hwc_display_contents_1_t* list) = 0; |
| 85 | /* allocates pipe from pipe book */ |
| 86 | virtual bool allocLayerPipes(hwc_context_t *ctx, |
| 87 | hwc_display_contents_1_t* list,FrameInfo& current_frame) = 0; |
| 88 | /* configures MPD pipes */ |
| 89 | virtual int configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 90 | PipeLayerPair& pipeLayerPair) = 0; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 91 | /* Is rotation supported */ |
| 92 | virtual bool canRotate(){ return true; }; |
| 93 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 94 | |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 95 | /* set/reset flags for MDPComp */ |
| 96 | void setMDPCompLayerFlags(hwc_context_t *ctx, |
| 97 | hwc_display_contents_1_t* list); |
| 98 | void unsetMDPCompLayerFlags(hwc_context_t* ctx, |
| 99 | hwc_display_contents_1_t* list); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 100 | /* get/set states */ |
| 101 | eState getState() { return mState; }; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 102 | /* reset state */ |
| 103 | void reset( hwc_context_t *ctx, hwc_display_contents_1_t* list ); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 104 | /* allocate MDP pipes from overlay */ |
| 105 | ovutils::eDest getMdpPipe(hwc_context_t *ctx, ePipeType type); |
| 106 | /* checks for conditions where mdpcomp is not possible */ |
| 107 | bool isDoable(hwc_context_t *ctx, hwc_display_contents_1_t* list); |
| 108 | /* sets up MDP comp for current frame */ |
| 109 | bool setup(hwc_context_t* ctx, hwc_display_contents_1_t* list); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 110 | /* set up Border fill as Base pipe */ |
| 111 | static bool setupBasePipe(hwc_context_t*); |
| 112 | /* Is debug enabled */ |
| 113 | static bool isDebug() { return sDebugLogs ? true : false; }; |
| 114 | /* Is feature enabled */ |
| 115 | static bool isEnabled() { return sEnabled; }; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 116 | /* checks for mdp comp width limitation */ |
| 117 | bool isWidthValid(hwc_context_t *ctx, hwc_layer_1_t *layer); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 118 | |
| 119 | eState mState; |
| 120 | |
| 121 | static bool sEnabled; |
| 122 | static bool sDebugLogs; |
| 123 | static bool sIdleFallBack; |
| 124 | static IdleInvalidator *idleInvalidator; |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 125 | struct FrameInfo mCurrentFrame; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 126 | }; |
| 127 | |
| 128 | class MDPCompLowRes : public MDPComp { |
| 129 | public: |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 130 | virtual ~MDPCompLowRes(){}; |
| 131 | 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] | 132 | |
| 133 | private: |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 134 | struct MdpPipeInfoLowRes : public MdpPipeInfo { |
| 135 | ovutils::eDest index; |
| 136 | virtual ~MdpPipeInfoLowRes() {}; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 137 | }; |
| 138 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 139 | /* configure's overlay pipes for the frame */ |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 140 | virtual int configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 141 | PipeLayerPair& pipeLayerPair); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 142 | |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 143 | /* allocates pipes to selected candidates */ |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 144 | virtual bool allocLayerPipes(hwc_context_t *ctx, |
Saurabh Shah | 3e858eb | 2012-09-17 16:53:21 -0700 | [diff] [blame] | 145 | hwc_display_contents_1_t* list, |
Naseer Ahmed | 54821fe | 2012-11-28 18:44:38 -0500 | [diff] [blame] | 146 | FrameInfo& current_frame); |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 147 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 148 | virtual int pipesNeeded(hwc_context_t *ctx, |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 149 | hwc_display_contents_1_t* list); |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 150 | }; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 151 | |
| 152 | class MDPCompHighRes : public MDPComp { |
| 153 | public: |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 154 | virtual ~MDPCompHighRes(){}; |
| 155 | virtual bool draw(hwc_context_t *ctx, hwc_display_contents_1_t *list); |
| 156 | private: |
| 157 | struct MdpPipeInfoHighRes : public MdpPipeInfo { |
| 158 | ovutils::eDest lIndex; |
| 159 | ovutils::eDest rIndex; |
| 160 | virtual ~MdpPipeInfoHighRes() {}; |
| 161 | }; |
Saurabh Shah | cbf7ccc | 2012-12-19 16:45:51 -0800 | [diff] [blame] | 162 | |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 163 | bool acquireMDPPipes(hwc_context_t *ctx, hwc_layer_1_t* layer, |
| 164 | MdpPipeInfoHighRes& pipe_info, ePipeType type); |
| 165 | |
| 166 | /* configure's overlay pipes for the frame */ |
| 167 | virtual int configure(hwc_context_t *ctx, hwc_layer_1_t *layer, |
Saurabh Shah | acf1020 | 2013-02-26 10:15:15 -0800 | [diff] [blame] | 168 | PipeLayerPair& pipeLayerPair); |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 169 | |
| 170 | /* allocates pipes to selected candidates */ |
| 171 | virtual bool allocLayerPipes(hwc_context_t *ctx, |
| 172 | hwc_display_contents_1_t* list, |
| 173 | FrameInfo& current_frame); |
| 174 | |
| 175 | virtual int pipesNeeded(hwc_context_t *ctx, hwc_display_contents_1_t* list); |
| 176 | virtual bool canRotate(){ return false; }; |
| 177 | }; |
Naseer Ahmed | 7c958d4 | 2012-07-31 18:57:03 -0700 | [diff] [blame] | 178 | }; //namespace |
| 179 | #endif |