blob: 45cd77bea0c1132e2a9ebf3dd89d6d7c48d695cd [file] [log] [blame]
Naseer Ahmed7c958d42012-07-31 18:57:03 -07001/*
Duy Truong73d36df2013-02-09 20:33:23 -08002 * Copyright (C) 2012, The Linux Foundation. All rights reserved.
Naseer Ahmed7c958d42012-07-31 18:57:03 -07003 * 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 Ahmed7c958d42012-07-31 18:57:03 -070027#define DEFAULT_IDLE_TIME 2000
Sushil Chauhan69f2bb22013-02-13 10:50:47 -080028#define MAX_PIPES_PER_MIXER 4
Naseer Ahmed7c958d42012-07-31 18:57:03 -070029
Naseer Ahmed7c958d42012-07-31 18:57:03 -070030namespace qhwc {
Naseer Ahmed54821fe2012-11-28 18:44:38 -050031namespace ovutils = overlay::utils;
Naseer Ahmed7c958d42012-07-31 18:57:03 -070032
33class MDPComp {
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -080034public:
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
49protected:
Naseer Ahmed54821fe2012-11-28 18:44:38 -050050 enum eState {
Naseer Ahmed7c958d42012-07-31 18:57:03 -070051 MDPCOMP_ON = 0,
52 MDPCOMP_OFF,
Naseer Ahmed7c958d42012-07-31 18:57:03 -070053 };
54
Naseer Ahmed54821fe2012-11-28 18:44:38 -050055 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 Ahmed7c958d42012-07-31 18:57:03 -070059 };
60
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -080061 /* 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
86class MDPCompLowRes : public MDPComp {
87public:
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
93private:
Naseer Ahmed54821fe2012-11-28 18:44:38 -050094 struct MdpPipeInfo {
Naseer Ahmed7c958d42012-07-31 18:57:03 -070095 int index;
Naseer Ahmed54821fe2012-11-28 18:44:38 -050096 int zOrder;
Naseer Ahmed7c958d42012-07-31 18:57:03 -070097 };
98
Naseer Ahmed54821fe2012-11-28 18:44:38 -050099 struct PipeLayerPair {
100 MdpPipeInfo pipeIndex;
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700101 native_handle_t* handle;
102 };
103
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500104 struct FrameInfo {
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700105 int count;
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500106 struct PipeLayerPair* pipeLayer;
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700107
108 };
Jeykumar Sankaranc18dbc22013-02-08 14:29:44 -0800109 /* checks for mdp comp width limitation */
110 bool isWidthValid(hwc_context_t *ctx, hwc_layer_1_t *layer);
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700111 /* configure's overlay pipes for the frame */
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800112 int configure(hwc_context_t *ctx, hwc_layer_1_t *layer,
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500113 MdpPipeInfo& mdp_info);
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700114 /* checks for conditions where mdpcomp is not possible */
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800115 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 Ahmed7c958d42012-07-31 18:57:03 -0700117 /* allocates pipes to selected candidates */
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800118 bool allocLayerPipes(hwc_context_t *ctx,
Saurabh Shah3e858eb2012-09-17 16:53:21 -0700119 hwc_display_contents_1_t* list,
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500120 FrameInfo& current_frame);
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700121 /* reset state */
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800122 void reset( hwc_context_t *ctx, hwc_display_contents_1_t* list );
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500123 /* configure MDP flags for video buffers */
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800124 void setVidInfo(hwc_layer_1_t *layer, ovutils::eMdpFlags &mdpFlags);
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500125 /* allocate MDP pipes from overlay */
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800126 int getMdpPipe(hwc_context_t *ctx, ePipeType type);
127
128 struct FrameInfo mCurrentFrame;
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700129};
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800130
131class MDPCompHighRes : public MDPComp {
132public:
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 Ahmed7c958d42012-07-31 18:57:03 -0700141}; //namespace
142#endif