blob: 6ff6385a275809d45077b60221b1efbd0af3a33f [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 {
Naseer Ahmed54821fe2012-11-28 18:44:38 -050033 enum eState {
Naseer Ahmed7c958d42012-07-31 18:57:03 -070034 MDPCOMP_ON = 0,
35 MDPCOMP_OFF,
Naseer Ahmed7c958d42012-07-31 18:57:03 -070036 };
37
Naseer Ahmed54821fe2012-11-28 18:44:38 -050038 enum ePipeType {
39 MDPCOMP_OV_RGB = ovutils::OV_MDP_PIPE_RGB,
40 MDPCOMP_OV_VG = ovutils::OV_MDP_PIPE_VG,
41 MDPCOMP_OV_ANY,
Naseer Ahmed7c958d42012-07-31 18:57:03 -070042 };
43
Naseer Ahmed54821fe2012-11-28 18:44:38 -050044 struct MdpPipeInfo {
Naseer Ahmed7c958d42012-07-31 18:57:03 -070045 int index;
Naseer Ahmed54821fe2012-11-28 18:44:38 -050046 int zOrder;
Naseer Ahmed7c958d42012-07-31 18:57:03 -070047 };
48
Naseer Ahmed54821fe2012-11-28 18:44:38 -050049 struct PipeLayerPair {
50 MdpPipeInfo pipeIndex;
Naseer Ahmed7c958d42012-07-31 18:57:03 -070051 native_handle_t* handle;
52 };
53
Naseer Ahmed54821fe2012-11-28 18:44:38 -050054 struct FrameInfo {
Naseer Ahmed7c958d42012-07-31 18:57:03 -070055 int count;
Naseer Ahmed54821fe2012-11-28 18:44:38 -050056 struct PipeLayerPair* pipeLayer;
Naseer Ahmed7c958d42012-07-31 18:57:03 -070057
58 };
59
Naseer Ahmed54821fe2012-11-28 18:44:38 -050060 static eState sMDPCompState;
Naseer Ahmed7c958d42012-07-31 18:57:03 -070061 static IdleInvalidator *idleInvalidator;
Naseer Ahmed54821fe2012-11-28 18:44:38 -050062 static struct FrameInfo sCurrentFrame;
63 static bool sEnabled;
Naseer Ahmed7c958d42012-07-31 18:57:03 -070064 static bool sDebugLogs;
65 static bool sIdleFallBack;
Naseer Ahmed54821fe2012-11-28 18:44:38 -050066 static int sActiveMax;
67 static bool sSecuredVid;
Naseer Ahmed7c958d42012-07-31 18:57:03 -070068
69public:
70 /* Handler to invoke frame redraw on Idle Timer expiry */
71 static void timeout_handler(void *udata);
72
73 /* configure/tear-down MDPComp params*/
74 static bool init(hwc_context_t *ctx);
75 static bool deinit();
Naseer Ahmed54821fe2012-11-28 18:44:38 -050076 static bool isUsed() { return (sMDPCompState == MDPCOMP_ON); };
Naseer Ahmed7c958d42012-07-31 18:57:03 -070077
78 /*sets up mdp comp for the current frame */
Naseer Ahmed54821fe2012-11-28 18:44:38 -050079 static bool configure(hwc_context_t *ctx,
80 hwc_display_contents_1_t* list);
Naseer Ahmed7c958d42012-07-31 18:57:03 -070081
82 /* draw */
Naseer Ahmed54821fe2012-11-28 18:44:38 -050083 static bool draw(hwc_context_t *ctx, hwc_display_contents_1_t *list);
Naseer Ahmed7c958d42012-07-31 18:57:03 -070084
Naseer Ahmed1d183f52012-11-26 12:35:16 -050085 static void dump(android::String8& buf);
86
Naseer Ahmed7c958d42012-07-31 18:57:03 -070087private:
Naseer Ahmed7c958d42012-07-31 18:57:03 -070088 /* set/reset flags for MDPComp */
Naseer Ahmed54821fe2012-11-28 18:44:38 -050089 static void setMDPCompLayerFlags(hwc_context_t *ctx,
90 hwc_display_contents_1_t* list);
Naseer Ahmed7c958d42012-07-31 18:57:03 -070091 static void unsetMDPCompLayerFlags(hwc_context_t* ctx,
Naseer Ahmed5b6708a2012-08-02 13:46:08 -070092 hwc_display_contents_1_t* list);
Naseer Ahmed7c958d42012-07-31 18:57:03 -070093
Naseer Ahmed5b6708a2012-08-02 13:46:08 -070094 static void print_info(hwc_layer_1_t* layer);
Naseer Ahmed7c958d42012-07-31 18:57:03 -070095
96 /* configure's overlay pipes for the frame */
Naseer Ahmed5b6708a2012-08-02 13:46:08 -070097 static int prepare(hwc_context_t *ctx, hwc_layer_1_t *layer,
Naseer Ahmed54821fe2012-11-28 18:44:38 -050098 MdpPipeInfo& mdp_info);
Naseer Ahmed7c958d42012-07-31 18:57:03 -070099
100 /* checks for conditions where mdpcomp is not possible */
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500101 static bool isDoable(hwc_context_t *ctx, hwc_display_contents_1_t* list);
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700102
Naseer Ahmed5b6708a2012-08-02 13:46:08 -0700103 static bool setup(hwc_context_t* ctx, hwc_display_contents_1_t* list);
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700104
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700105 /* allocates pipes to selected candidates */
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500106 static bool allocLayerPipes(hwc_context_t *ctx,
Saurabh Shah3e858eb2012-09-17 16:53:21 -0700107 hwc_display_contents_1_t* list,
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500108 FrameInfo& current_frame);
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700109
110 /* get/set states */
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500111 static eState getState() { return sMDPCompState; };
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700112
113 /* reset state */
Naseer Ahmed5b6708a2012-08-02 13:46:08 -0700114 static void reset( hwc_context_t *ctx, hwc_display_contents_1_t* list );
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700115
116 /* Is feature enabled */
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500117 static bool isEnabled() { return sEnabled; };
118
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700119 /* Is debug enabled */
120 static bool isDebug() { return sDebugLogs ? true : false; };
Naseer Ahmed54821fe2012-11-28 18:44:38 -0500121
122 /* check layer state */
123 static bool isSkipPresent (hwc_context_t *ctx);
124 static bool isYuvPresent (hwc_context_t *ctx);
125
126 /* configure MDP flags for video buffers */
127 static void setVidInfo(hwc_layer_1_t *layer, ovutils::eMdpFlags &mdpFlags);
128
129 /* set up Border fill as Base pipe */
130 static bool setupBasePipe(hwc_context_t*);
131
132 /* allocate MDP pipes from overlay */
133 static int getMdpPipe(hwc_context_t *ctx, ePipeType type);
Naseer Ahmed7c958d42012-07-31 18:57:03 -0700134};
135}; //namespace
136#endif