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