blob: 4dc5878d4c30c4f7d90f3d98220a50ef642b3d28 [file] [log] [blame]
Naseer Ahmed7c958d42012-07-31 18:57:03 -07001/*
2 * Copyright (C) 2012, Code Aurora Forum. All rights reserved.
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 Ahmed7c958d42012-07-31 18:57:03 -070027#define DEFAULT_IDLE_TIME 2000
28
Naseer Ahmed7c958d42012-07-31 18:57:03 -070029namespace qhwc {
Naseer Ahmed54821fe2012-11-28 18:44:38 -050030namespace ovutils = overlay::utils;
Naseer Ahmed7c958d42012-07-31 18:57:03 -070031
32class MDPComp {
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -080033public:
34 virtual ~MDPComp() {}
35 /*sets up mdp comp for the current frame */
36 virtual bool prepare(hwc_context_t *ctx,
37 hwc_display_contents_1_t* list) = 0;
38 /* draw */
39 virtual bool draw(hwc_context_t *ctx, hwc_display_contents_1_t *list) = 0;
40 void dump(android::String8& buf);
41 bool isUsed() { return (mState == MDPCOMP_ON); };
42
43 static MDPComp* getObject(const int& width);
44 /* Handler to invoke frame redraw on Idle Timer expiry */
45 static void timeout_handler(void *udata);
46 static bool init(hwc_context_t *ctx);
47
48protected:
Naseer Ahmed54821fe2012-11-28 18:44:38 -050049 enum eState {
Naseer Ahmed7c958d42012-07-31 18:57:03 -070050 MDPCOMP_ON = 0,
51 MDPCOMP_OFF,
Naseer Ahmed7c958d42012-07-31 18:57:03 -070052 };
53
Naseer Ahmed54821fe2012-11-28 18:44:38 -050054 enum ePipeType {
55 MDPCOMP_OV_RGB = ovutils::OV_MDP_PIPE_RGB,
56 MDPCOMP_OV_VG = ovutils::OV_MDP_PIPE_VG,
57 MDPCOMP_OV_ANY,
Naseer Ahmed7c958d42012-07-31 18:57:03 -070058 };
59
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -080060 /* set/reset flags for MDPComp */
61 void setMDPCompLayerFlags(hwc_context_t *ctx,
62 hwc_display_contents_1_t* list);
63 void unsetMDPCompLayerFlags(hwc_context_t* ctx,
64 hwc_display_contents_1_t* list);
65 void printInfo(hwc_layer_1_t* layer);
66 /* get/set states */
67 eState getState() { return mState; };
68
69 /* set up Border fill as Base pipe */
70 static bool setupBasePipe(hwc_context_t*);
71 /* Is debug enabled */
72 static bool isDebug() { return sDebugLogs ? true : false; };
73 /* Is feature enabled */
74 static bool isEnabled() { return sEnabled; };
75
76 eState mState;
77
78 static bool sEnabled;
79 static bool sDebugLogs;
80 static bool sIdleFallBack;
81 static IdleInvalidator *idleInvalidator;
82
83};
84
85class MDPCompLowRes : public MDPComp {
86public:
87 virtual ~MDPCompLowRes() {}
88 virtual bool prepare(hwc_context_t *ctx,
89 hwc_display_contents_1_t* list);
90 virtual bool draw(hwc_context_t *ctx, hwc_display_contents_1_t *list);
91
92private:
Naseer Ahmed54821fe2012-11-28 18:44:38 -050093 struct MdpPipeInfo {
Naseer Ahmed7c958d42012-07-31 18:57:03 -070094 int index;
Naseer Ahmed54821fe2012-11-28 18:44:38 -050095 int zOrder;
Naseer Ahmed7c958d42012-07-31 18:57:03 -070096 };
97
Naseer Ahmed54821fe2012-11-28 18:44:38 -050098 struct PipeLayerPair {
99 MdpPipeInfo pipeIndex;
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700100 native_handle_t* handle;
101 };
102
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500103 struct FrameInfo {
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700104 int count;
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500105 struct PipeLayerPair* pipeLayer;
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700106
107 };
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700108 /* configure's overlay pipes for the frame */
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800109 int configure(hwc_context_t *ctx, hwc_layer_1_t *layer,
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500110 MdpPipeInfo& mdp_info);
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700111 /* checks for conditions where mdpcomp is not possible */
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800112 bool isDoable(hwc_context_t *ctx, hwc_display_contents_1_t* list);
113 bool setup(hwc_context_t* ctx, hwc_display_contents_1_t* list);
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700114 /* allocates pipes to selected candidates */
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800115 bool allocLayerPipes(hwc_context_t *ctx,
Saurabh Shah3e858eb2012-09-17 16:53:21 -0700116 hwc_display_contents_1_t* list,
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500117 FrameInfo& current_frame);
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700118 /* reset state */
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800119 void reset( hwc_context_t *ctx, hwc_display_contents_1_t* list );
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500120 /* configure MDP flags for video buffers */
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800121 void setVidInfo(hwc_layer_1_t *layer, ovutils::eMdpFlags &mdpFlags);
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500122 /* allocate MDP pipes from overlay */
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800123 int getMdpPipe(hwc_context_t *ctx, ePipeType type);
124
125 struct FrameInfo mCurrentFrame;
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700126};
Saurabh Shahcbf7ccc2012-12-19 16:45:51 -0800127
128class MDPCompHighRes : public MDPComp {
129public:
130 virtual ~MDPCompHighRes() {}
131 virtual bool prepare(hwc_context_t *ctx,
132 hwc_display_contents_1_t* list) { return false; }
133 virtual bool draw(hwc_context_t *ctx, hwc_display_contents_1_t *list) {
134 return true;
135 }
136};
137
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700138}; //namespace
139#endif