blob: d847f5668292d1088404833ac0a4bdd232ebb8ea [file] [log] [blame]
Naseer Ahmed7c958d42012-07-31 18:57:03 -07001/*
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -08002 * Copyright (C) 2012-2013, The Linux Foundation. All rights reserved.
3 *
Naseer Ahmed7c958d42012-07-31 18:57:03 -07004 * 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 Ahmed7c958d42012-07-31 18:57:03 -070028#define DEFAULT_IDLE_TIME 2000
Sushil Chauhan69f2bb22013-02-13 10:50:47 -080029#define MAX_PIPES_PER_MIXER 4
Naseer Ahmed7c958d42012-07-31 18:57:03 -070030
Saurabh Shahacf10202013-02-26 10:15:15 -080031namespace overlay {
32 class Rotator;
33};
34
Naseer Ahmed7c958d42012-07-31 18:57:03 -070035namespace qhwc {
Naseer Ahmed54821fe2012-11-28 18:44:38 -050036namespace ovutils = overlay::utils;
Naseer Ahmed7c958d42012-07-31 18:57:03 -070037
38class MDPComp {
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -080039public:
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -080040 virtual ~MDPComp(){};
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -080041 /*sets up mdp comp for the current frame */
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -080042 bool prepare(hwc_context_t *ctx, hwc_display_contents_1_t* list);
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -080043 /* draw */
44 virtual bool draw(hwc_context_t *ctx, hwc_display_contents_1_t *list) = 0;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -080045
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -080046 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
54protected:
Naseer Ahmed54821fe2012-11-28 18:44:38 -050055 enum eState {
Naseer Ahmed7c958d42012-07-31 18:57:03 -070056 MDPCOMP_ON = 0,
57 MDPCOMP_OFF,
Naseer Ahmed7c958d42012-07-31 18:57:03 -070058 };
59
Naseer Ahmed54821fe2012-11-28 18:44:38 -050060 enum ePipeType {
61 MDPCOMP_OV_RGB = ovutils::OV_MDP_PIPE_RGB,
62 MDPCOMP_OV_VG = ovutils::OV_MDP_PIPE_VG,
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -080063 MDPCOMP_OV_DMA = ovutils::OV_MDP_PIPE_DMA,
Naseer Ahmed54821fe2012-11-28 18:44:38 -050064 MDPCOMP_OV_ANY,
Naseer Ahmed7c958d42012-07-31 18:57:03 -070065 };
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -080066 struct MdpPipeInfo {
67 int zOrder;
68 virtual ~MdpPipeInfo(){};
69 };
70 struct PipeLayerPair {
71 MdpPipeInfo *pipeInfo;
72 native_handle_t* handle;
Saurabh Shahacf10202013-02-26 10:15:15 -080073 overlay::Rotator* rot;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -080074 };
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 Shahacf10202013-02-26 10:15:15 -080090 PipeLayerPair& pipeLayerPair) = 0;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -080091
Naseer Ahmed7c958d42012-07-31 18:57:03 -070092
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -080093 /* set/reset flags for MDPComp */
94 void setMDPCompLayerFlags(hwc_context_t *ctx,
95 hwc_display_contents_1_t* list);
96 void unsetMDPCompLayerFlags(hwc_context_t* ctx,
97 hwc_display_contents_1_t* list);
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -080098 /* get/set states */
99 eState getState() { return mState; };
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800100 /* reset state */
101 void reset( hwc_context_t *ctx, hwc_display_contents_1_t* list );
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800102 /* 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 Shahcbf7ccc2012-12-19 16:45:51 -0800108 /* 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 Sankaranb551ce42013-01-10 16:26:48 -0800114 /* checks for mdp comp width limitation */
115 bool isWidthValid(hwc_context_t *ctx, hwc_layer_1_t *layer);
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800116
117 eState mState;
118
119 static bool sEnabled;
120 static bool sDebugLogs;
121 static bool sIdleFallBack;
122 static IdleInvalidator *idleInvalidator;
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800123 struct FrameInfo mCurrentFrame;
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800124};
125
126class MDPCompLowRes : public MDPComp {
127public:
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800128 virtual ~MDPCompLowRes(){};
129 virtual bool draw(hwc_context_t *ctx, hwc_display_contents_1_t *list);
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800130
131private:
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800132 struct MdpPipeInfoLowRes : public MdpPipeInfo {
133 ovutils::eDest index;
134 virtual ~MdpPipeInfoLowRes() {};
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700135 };
136
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700137 /* configure's overlay pipes for the frame */
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800138 virtual int configure(hwc_context_t *ctx, hwc_layer_1_t *layer,
Saurabh Shahacf10202013-02-26 10:15:15 -0800139 PipeLayerPair& pipeLayerPair);
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800140
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700141 /* allocates pipes to selected candidates */
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800142 virtual bool allocLayerPipes(hwc_context_t *ctx,
Saurabh Shah3e858eb2012-09-17 16:53:21 -0700143 hwc_display_contents_1_t* list,
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500144 FrameInfo& current_frame);
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800145
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800146 virtual int pipesNeeded(hwc_context_t *ctx,
Saurabh Shahacf10202013-02-26 10:15:15 -0800147 hwc_display_contents_1_t* list);
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700148};
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800149
150class MDPCompHighRes : public MDPComp {
151public:
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800152 virtual ~MDPCompHighRes(){};
153 virtual bool draw(hwc_context_t *ctx, hwc_display_contents_1_t *list);
154private:
155 struct MdpPipeInfoHighRes : public MdpPipeInfo {
156 ovutils::eDest lIndex;
157 ovutils::eDest rIndex;
158 virtual ~MdpPipeInfoHighRes() {};
159 };
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800160
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800161 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,
Saurabh Shahacf10202013-02-26 10:15:15 -0800166 PipeLayerPair& pipeLayerPair);
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800167
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);
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800174};
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700175}; //namespace
176#endif