Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 1 | /* |
Sushil Chauhan | 07a2c76 | 2013-03-06 15:36:49 -0800 | [diff] [blame] | 2 | * Copyright (c) 2011-2013, The Linux Foundation. All rights reserved. |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions are |
| 6 | * met: |
| 7 | * * Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * * Redistributions in binary form must reproduce the above |
| 10 | * copyright notice, this list of conditions and the following |
| 11 | * disclaimer in the documentation and/or other materials provided |
| 12 | * with the distribution. |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 13 | * * Neither the name of The Linux Foundation nor the names of its |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 14 | * contributors may be used to endorse or promote products derived |
| 15 | * from this software without specific prior written permission. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 24 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 27 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | */ |
| 29 | |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 30 | #include "overlay.h" |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 31 | #include "pipes/overlayGenPipe.h" |
| 32 | #include "mdp_version.h" |
Saurabh Shah | 5daeee5 | 2013-01-23 16:52:26 +0800 | [diff] [blame] | 33 | #include "qdMetaData.h" |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 34 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 35 | #define PIPE_DEBUG 0 |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 36 | |
| 37 | namespace overlay { |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 38 | using namespace utils; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 39 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 40 | Overlay::Overlay() { |
Sushil Chauhan | 07a2c76 | 2013-03-06 15:36:49 -0800 | [diff] [blame] | 41 | PipeBook::NUM_PIPES = qdutils::MDPVersion::getInstance().getTotalPipes(); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 42 | for(int i = 0; i < PipeBook::NUM_PIPES; i++) { |
| 43 | mPipeBook[i].init(); |
Naseer Ahmed | 1ddf366 | 2012-07-31 19:14:18 -0700 | [diff] [blame] | 44 | } |
Naseer Ahmed | 1ddf366 | 2012-07-31 19:14:18 -0700 | [diff] [blame] | 45 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 46 | mDumpStr[0] = '\0'; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | Overlay::~Overlay() { |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 50 | for(int i = 0; i < PipeBook::NUM_PIPES; i++) { |
| 51 | mPipeBook[i].destroy(); |
| 52 | } |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 53 | } |
| 54 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 55 | void Overlay::configBegin() { |
| 56 | for(int i = 0; i < PipeBook::NUM_PIPES; i++) { |
| 57 | //Mark as available for this round. |
| 58 | PipeBook::resetUse(i); |
| 59 | PipeBook::resetAllocation(i); |
| 60 | } |
Saurabh Shah | 784e985 | 2013-08-21 16:51:21 -0700 | [diff] [blame^] | 61 | sForceSetBitmap = 0; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 62 | mDumpStr[0] = '\0'; |
| 63 | } |
| 64 | |
| 65 | void Overlay::configDone() { |
| 66 | if(PipeBook::pipeUsageUnchanged()) return; |
| 67 | |
| 68 | for(int i = 0; i < PipeBook::NUM_PIPES; i++) { |
| 69 | if(PipeBook::isNotUsed(i)) { |
| 70 | //Forces UNSET on pipes, flushes rotator memory and session, closes |
| 71 | //fds |
| 72 | if(mPipeBook[i].valid()) { |
| 73 | char str[32]; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 74 | sprintf(str, "Unset=%s dpy=%d mix=%d; ", |
| 75 | PipeBook::getDestStr((eDest)i), |
| 76 | mPipeBook[i].mDisplay, mPipeBook[i].mMixer); |
Saurabh Shah | 9dc88fc | 2013-07-15 16:02:30 -0700 | [diff] [blame] | 77 | #if PIPE_DEBUG |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 78 | strncat(mDumpStr, str, strlen(str)); |
Saurabh Shah | 9dc88fc | 2013-07-15 16:02:30 -0700 | [diff] [blame] | 79 | #endif |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 80 | } |
| 81 | mPipeBook[i].destroy(); |
Naseer Ahmed | 1ddf366 | 2012-07-31 19:14:18 -0700 | [diff] [blame] | 82 | } |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 83 | } |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 84 | dump(); |
| 85 | PipeBook::save(); |
| 86 | } |
| 87 | |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 88 | eDest Overlay::nextPipe(eMdpPipeType type, int dpy, int mixer) { |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 89 | eDest dest = OV_INVALID; |
| 90 | |
| 91 | for(int i = 0; i < PipeBook::NUM_PIPES; i++) { |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 92 | if( (type == OV_MDP_PIPE_ANY || //Pipe type match |
| 93 | type == PipeBook::getPipeType((eDest)i)) && |
| 94 | (mPipeBook[i].mDisplay == DPY_UNUSED || //Free or same display |
| 95 | mPipeBook[i].mDisplay == dpy) && |
| 96 | (mPipeBook[i].mMixer == MIXER_UNUSED || //Free or same mixer |
| 97 | mPipeBook[i].mMixer == mixer) && |
| 98 | PipeBook::isNotAllocated(i) && //Free pipe |
| 99 | !(sDMAMode == DMA_BLOCK_MODE && //DMA pipe in Line mode |
| 100 | PipeBook::getPipeType((eDest)i) == OV_MDP_PIPE_DMA)) { |
| 101 | dest = (eDest)i; |
| 102 | PipeBook::setAllocation(i); |
| 103 | break; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 104 | } |
| 105 | } |
| 106 | |
| 107 | if(dest != OV_INVALID) { |
| 108 | int index = (int)dest; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 109 | mPipeBook[index].mDisplay = dpy; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 110 | mPipeBook[index].mMixer = mixer; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 111 | if(not mPipeBook[index].valid()) { |
| 112 | mPipeBook[index].mPipe = new GenericPipe(dpy); |
| 113 | char str[32]; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 114 | snprintf(str, 32, "Set=%s dpy=%d mix=%d; ", |
| 115 | PipeBook::getDestStr(dest), dpy, mixer); |
Saurabh Shah | 9dc88fc | 2013-07-15 16:02:30 -0700 | [diff] [blame] | 116 | #if PIPE_DEBUG |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 117 | strncat(mDumpStr, str, strlen(str)); |
Saurabh Shah | 9dc88fc | 2013-07-15 16:02:30 -0700 | [diff] [blame] | 118 | #endif |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 119 | } |
| 120 | } else { |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 121 | ALOGD_IF(PIPE_DEBUG, "Pipe unavailable type=%d display=%d mixer=%d", |
| 122 | (int)type, dpy, mixer); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 123 | } |
| 124 | |
| 125 | return dest; |
| 126 | } |
| 127 | |
Saurabh Shah | 0ceeb6a | 2013-04-23 10:46:07 -0700 | [diff] [blame] | 128 | bool Overlay::isPipeTypeAttached(eMdpPipeType type) { |
| 129 | for(int i = 0; i < PipeBook::NUM_PIPES; i++) { |
| 130 | if(type == PipeBook::getPipeType((eDest)i) && |
Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 131 | mPipeBook[i].mDisplay != DPY_UNUSED) { |
Saurabh Shah | 0ceeb6a | 2013-04-23 10:46:07 -0700 | [diff] [blame] | 132 | return true; |
| 133 | } |
| 134 | } |
| 135 | return false; |
| 136 | } |
| 137 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 138 | bool Overlay::commit(utils::eDest dest) { |
| 139 | bool ret = false; |
| 140 | int index = (int)dest; |
| 141 | validate(index); |
| 142 | |
| 143 | if(mPipeBook[index].mPipe->commit()) { |
| 144 | ret = true; |
| 145 | PipeBook::setUse((int)dest); |
Saurabh Shah | 784e985 | 2013-08-21 16:51:21 -0700 | [diff] [blame^] | 146 | if(sForceSetBitmap & (1 << mPipeBook[index].mDisplay)) { |
| 147 | mPipeBook[index].mPipe->forceSet(); |
| 148 | } |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 149 | } else { |
Sushil Chauhan | e0dff93 | 2013-03-01 14:33:18 -0800 | [diff] [blame] | 150 | int dpy = mPipeBook[index].mDisplay; |
| 151 | for(int i = 0; i < PipeBook::NUM_PIPES; i++) |
Saurabh Shah | df0be75 | 2013-05-23 14:40:00 -0700 | [diff] [blame] | 152 | if (mPipeBook[i].mDisplay == dpy) { |
Sushil Chauhan | e0dff93 | 2013-03-01 14:33:18 -0800 | [diff] [blame] | 153 | PipeBook::resetAllocation(i); |
Saurabh Shah | df0be75 | 2013-05-23 14:40:00 -0700 | [diff] [blame] | 154 | PipeBook::resetUse(i); |
| 155 | if(mPipeBook[i].valid()) { |
| 156 | mPipeBook[i].mPipe->forceSet(); |
| 157 | } |
| 158 | } |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 159 | } |
| 160 | return ret; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 161 | } |
| 162 | |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 163 | bool Overlay::queueBuffer(int fd, uint32_t offset, |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 164 | utils::eDest dest) { |
| 165 | int index = (int)dest; |
| 166 | bool ret = false; |
| 167 | validate(index); |
| 168 | //Queue only if commit() has succeeded (and the bit set) |
| 169 | if(PipeBook::isUsed((int)dest)) { |
| 170 | ret = mPipeBook[index].mPipe->queueBuffer(fd, offset); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 171 | } |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 172 | return ret; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 173 | } |
| 174 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 175 | void Overlay::setCrop(const utils::Dim& d, |
| 176 | utils::eDest dest) { |
| 177 | int index = (int)dest; |
| 178 | validate(index); |
| 179 | mPipeBook[index].mPipe->setCrop(d); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 180 | } |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 181 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 182 | void Overlay::setPosition(const utils::Dim& d, |
| 183 | utils::eDest dest) { |
| 184 | int index = (int)dest; |
| 185 | validate(index); |
| 186 | mPipeBook[index].mPipe->setPosition(d); |
| 187 | } |
| 188 | |
| 189 | void Overlay::setTransform(const int orient, |
| 190 | utils::eDest dest) { |
| 191 | int index = (int)dest; |
| 192 | validate(index); |
| 193 | |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 194 | utils::eTransform transform = |
| 195 | static_cast<utils::eTransform>(orient); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 196 | mPipeBook[index].mPipe->setTransform(transform); |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 197 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | void Overlay::setSource(const utils::PipeArgs args, |
| 201 | utils::eDest dest) { |
| 202 | int index = (int)dest; |
| 203 | validate(index); |
| 204 | |
| 205 | PipeArgs newArgs(args); |
Sushil Chauhan | 07a2c76 | 2013-03-06 15:36:49 -0800 | [diff] [blame] | 206 | if(PipeBook::getPipeType(dest) == OV_MDP_PIPE_VG) { |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 207 | setMdpFlags(newArgs.mdpFlags, OV_MDP_PIPE_SHARE); |
| 208 | } else { |
| 209 | clearMdpFlags(newArgs.mdpFlags, OV_MDP_PIPE_SHARE); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 210 | } |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 211 | |
Sushil Chauhan | 07a2c76 | 2013-03-06 15:36:49 -0800 | [diff] [blame] | 212 | if(PipeBook::getPipeType(dest) == OV_MDP_PIPE_DMA) { |
Jeykumar Sankaran | b551ce4 | 2013-01-10 16:26:48 -0800 | [diff] [blame] | 213 | setMdpFlags(newArgs.mdpFlags, OV_MDP_PIPE_FORCE_DMA); |
| 214 | } else { |
| 215 | clearMdpFlags(newArgs.mdpFlags, OV_MDP_PIPE_FORCE_DMA); |
| 216 | } |
| 217 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 218 | mPipeBook[index].mPipe->setSource(newArgs); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 219 | } |
Naseer Ahmed | f48aef6 | 2012-07-20 09:05:53 -0700 | [diff] [blame] | 220 | |
Saurabh Shah | 5daeee5 | 2013-01-23 16:52:26 +0800 | [diff] [blame] | 221 | void Overlay::setVisualParams(const MetaData_t& metadata, utils::eDest dest) { |
| 222 | int index = (int)dest; |
| 223 | validate(index); |
| 224 | mPipeBook[index].mPipe->setVisualParams(metadata); |
| 225 | } |
| 226 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 227 | Overlay* Overlay::getInstance() { |
| 228 | if(sInstance == NULL) { |
| 229 | sInstance = new Overlay(); |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 230 | } |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 231 | return sInstance; |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 232 | } |
| 233 | |
Sushil Chauhan | 07a2c76 | 2013-03-06 15:36:49 -0800 | [diff] [blame] | 234 | // Clears any VG pipes allocated to the fb devices |
| 235 | // Generates a LUT for pipe types. |
| 236 | int Overlay::initOverlay() { |
| 237 | int mdpVersion = qdutils::MDPVersion::getInstance().getMDPVersion(); |
| 238 | int numPipesXType[OV_MDP_PIPE_ANY] = {0}; |
| 239 | numPipesXType[OV_MDP_PIPE_RGB] = |
| 240 | qdutils::MDPVersion::getInstance().getRGBPipes(); |
| 241 | numPipesXType[OV_MDP_PIPE_VG] = |
| 242 | qdutils::MDPVersion::getInstance().getVGPipes(); |
| 243 | numPipesXType[OV_MDP_PIPE_DMA] = |
| 244 | qdutils::MDPVersion::getInstance().getDMAPipes(); |
| 245 | |
| 246 | int index = 0; |
| 247 | for(int X = 0; X < (int)OV_MDP_PIPE_ANY; X++) { //iterate over types |
| 248 | for(int j = 0; j < numPipesXType[X]; j++) { //iterate over num |
| 249 | PipeBook::pipeTypeLUT[index] = (utils::eMdpPipeType)X; |
| 250 | index++; |
| 251 | } |
Saurabh Shah | c4d034f | 2012-09-27 15:55:15 -0700 | [diff] [blame] | 252 | } |
Sushil Chauhan | 07a2c76 | 2013-03-06 15:36:49 -0800 | [diff] [blame] | 253 | |
Xiaoming Zhou | 5eff8b6 | 2013-05-01 20:56:09 -0400 | [diff] [blame] | 254 | if (mdpVersion < qdutils::MDSS_V5 && mdpVersion != qdutils::MDP_V3_0_4) { |
Sushil Chauhan | 07a2c76 | 2013-03-06 15:36:49 -0800 | [diff] [blame] | 255 | msmfb_mixer_info_req req; |
| 256 | mdp_mixer_info *minfo = NULL; |
| 257 | char name[64]; |
| 258 | int fd = -1; |
Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 259 | for(int i = 0; i < MAX_FB_DEVICES; i++) { |
Sushil Chauhan | 07a2c76 | 2013-03-06 15:36:49 -0800 | [diff] [blame] | 260 | snprintf(name, 64, FB_DEVICE_TEMPLATE, i); |
| 261 | ALOGD("initoverlay:: opening the device:: %s", name); |
| 262 | fd = ::open(name, O_RDWR, 0); |
| 263 | if(fd < 0) { |
| 264 | ALOGE("cannot open framebuffer(%d)", i); |
| 265 | return -1; |
| 266 | } |
| 267 | //Get the mixer configuration */ |
| 268 | req.mixer_num = i; |
| 269 | if (ioctl(fd, MSMFB_MIXER_INFO, &req) == -1) { |
| 270 | ALOGE("ERROR: MSMFB_MIXER_INFO ioctl failed"); |
| 271 | close(fd); |
| 272 | return -1; |
| 273 | } |
| 274 | minfo = req.info; |
| 275 | for (int j = 0; j < req.cnt; j++) { |
| 276 | ALOGD("ndx=%d num=%d z_order=%d", minfo->pndx, minfo->pnum, |
| 277 | minfo->z_order); |
| 278 | // except the RGB base layer with z_order of -1, clear any |
| 279 | // other pipes connected to mixer. |
| 280 | if((minfo->z_order) != -1) { |
| 281 | int index = minfo->pndx; |
| 282 | ALOGD("Unset overlay with index: %d at mixer %d", index, i); |
| 283 | if(ioctl(fd, MSMFB_OVERLAY_UNSET, &index) == -1) { |
| 284 | ALOGE("ERROR: MSMFB_OVERLAY_UNSET failed"); |
| 285 | close(fd); |
| 286 | return -1; |
| 287 | } |
| 288 | } |
| 289 | minfo++; |
| 290 | } |
| 291 | close(fd); |
| 292 | fd = -1; |
| 293 | } |
| 294 | } |
Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 295 | |
| 296 | FILE *displayDeviceFP = NULL; |
| 297 | const int MAX_FRAME_BUFFER_NAME_SIZE = 128; |
| 298 | char fbType[MAX_FRAME_BUFFER_NAME_SIZE]; |
| 299 | char msmFbTypePath[MAX_FRAME_BUFFER_NAME_SIZE]; |
| 300 | const char *strDtvPanel = "dtv panel"; |
| 301 | const char *strWbPanel = "writeback panel"; |
| 302 | |
| 303 | for(int num = 1; num < MAX_FB_DEVICES; num++) { |
| 304 | snprintf (msmFbTypePath, sizeof(msmFbTypePath), |
| 305 | "/sys/class/graphics/fb%d/msm_fb_type", num); |
| 306 | displayDeviceFP = fopen(msmFbTypePath, "r"); |
| 307 | |
| 308 | if(displayDeviceFP){ |
| 309 | fread(fbType, sizeof(char), MAX_FRAME_BUFFER_NAME_SIZE, |
| 310 | displayDeviceFP); |
| 311 | |
| 312 | if(strncmp(fbType, strDtvPanel, strlen(strDtvPanel)) == 0) { |
| 313 | sDpyFbMap[DPY_EXTERNAL] = num; |
| 314 | } else if(strncmp(fbType, strWbPanel, strlen(strWbPanel)) == 0) { |
| 315 | sDpyFbMap[DPY_WRITEBACK] = num; |
| 316 | } |
| 317 | |
| 318 | fclose(displayDeviceFP); |
| 319 | } |
| 320 | } |
| 321 | |
Sushil Chauhan | 07a2c76 | 2013-03-06 15:36:49 -0800 | [diff] [blame] | 322 | return 0; |
Naseer Ahmed | 29a2681 | 2012-06-14 00:56:20 -0700 | [diff] [blame] | 323 | } |
| 324 | |
Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 325 | bool Overlay::displayCommit(const int& fd) { |
| 326 | //Commit |
| 327 | struct mdp_display_commit info; |
| 328 | memset(&info, 0, sizeof(struct mdp_display_commit)); |
| 329 | info.flags = MDP_DISPLAY_COMMIT_OVERLAY; |
| 330 | if(!mdp_wrapper::displayCommit(fd, info)) { |
| 331 | ALOGE("%s: commit failed", __func__); |
| 332 | return false; |
| 333 | } |
| 334 | return true; |
| 335 | } |
| 336 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 337 | void Overlay::dump() const { |
Saurabh Shah | 9dc88fc | 2013-07-15 16:02:30 -0700 | [diff] [blame] | 338 | #if PIPE_DEBUG |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 339 | if(strlen(mDumpStr)) { //dump only on state change |
Saurabh Shah | 9dc88fc | 2013-07-15 16:02:30 -0700 | [diff] [blame] | 340 | ALOGD("%s\n", mDumpStr); |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 341 | } |
Saurabh Shah | 9dc88fc | 2013-07-15 16:02:30 -0700 | [diff] [blame] | 342 | #endif |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 343 | } |
| 344 | |
Saurabh Shah | 0d0a7cb | 2013-02-12 17:58:19 -0800 | [diff] [blame] | 345 | void Overlay::getDump(char *buf, size_t len) { |
| 346 | int totalPipes = 0; |
Saurabh Shah | ae61b2b | 2013-04-10 16:37:25 -0700 | [diff] [blame] | 347 | const char *str = "\nOverlay State\n\n"; |
Saurabh Shah | 0d0a7cb | 2013-02-12 17:58:19 -0800 | [diff] [blame] | 348 | strncat(buf, str, strlen(str)); |
| 349 | for(int i = 0; i < PipeBook::NUM_PIPES; i++) { |
| 350 | if(mPipeBook[i].valid()) { |
| 351 | mPipeBook[i].mPipe->getDump(buf, len); |
| 352 | char str[64] = {'\0'}; |
Saurabh Shah | ae61b2b | 2013-04-10 16:37:25 -0700 | [diff] [blame] | 353 | snprintf(str, 64, "Display=%d\n\n", mPipeBook[i].mDisplay); |
Saurabh Shah | 0d0a7cb | 2013-02-12 17:58:19 -0800 | [diff] [blame] | 354 | strncat(buf, str, strlen(str)); |
| 355 | totalPipes++; |
| 356 | } |
| 357 | } |
| 358 | char str_pipes[64] = {'\0'}; |
Saurabh Shah | ae61b2b | 2013-04-10 16:37:25 -0700 | [diff] [blame] | 359 | snprintf(str_pipes, 64, "Pipes=%d\n\n", totalPipes); |
Saurabh Shah | 0d0a7cb | 2013-02-12 17:58:19 -0800 | [diff] [blame] | 360 | strncat(buf, str_pipes, strlen(str_pipes)); |
| 361 | } |
| 362 | |
Sushil Chauhan | bd3ea92 | 2013-05-15 12:25:26 -0700 | [diff] [blame] | 363 | void Overlay::clear(int dpy) { |
| 364 | for(int i = 0; i < PipeBook::NUM_PIPES; i++) { |
| 365 | if (mPipeBook[i].mDisplay == dpy) { |
| 366 | // Mark as available for this round |
| 367 | PipeBook::resetUse(i); |
| 368 | PipeBook::resetAllocation(i); |
Saurabh Shah | df0be75 | 2013-05-23 14:40:00 -0700 | [diff] [blame] | 369 | if(mPipeBook[i].valid()) { |
| 370 | mPipeBook[i].mPipe->forceSet(); |
| 371 | } |
Sushil Chauhan | bd3ea92 | 2013-05-15 12:25:26 -0700 | [diff] [blame] | 372 | } |
| 373 | } |
| 374 | } |
| 375 | |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 376 | void Overlay::PipeBook::init() { |
| 377 | mPipe = NULL; |
| 378 | mDisplay = DPY_UNUSED; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 379 | mMixer = MIXER_UNUSED; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | void Overlay::PipeBook::destroy() { |
| 383 | if(mPipe) { |
| 384 | delete mPipe; |
| 385 | mPipe = NULL; |
| 386 | } |
| 387 | mDisplay = DPY_UNUSED; |
Saurabh Shah | af5f597 | 2013-07-30 13:56:35 -0700 | [diff] [blame] | 388 | mMixer = MIXER_UNUSED; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 389 | } |
| 390 | |
| 391 | Overlay* Overlay::sInstance = 0; |
Saurabh Shah | c8118ac | 2013-06-27 10:03:19 -0700 | [diff] [blame] | 392 | int Overlay::sDpyFbMap[DPY_MAX] = {0, -1, -1}; |
Saurabh Shah | 85234ec | 2013-04-12 17:09:00 -0700 | [diff] [blame] | 393 | int Overlay::sDMAMode = DMA_LINE_MODE; |
Saurabh Shah | 784e985 | 2013-08-21 16:51:21 -0700 | [diff] [blame^] | 394 | int Overlay::sForceSetBitmap = 0; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 395 | int Overlay::PipeBook::NUM_PIPES = 0; |
| 396 | int Overlay::PipeBook::sPipeUsageBitmap = 0; |
| 397 | int Overlay::PipeBook::sLastUsageBitmap = 0; |
| 398 | int Overlay::PipeBook::sAllocatedBitmap = 0; |
Sushil Chauhan | 07a2c76 | 2013-03-06 15:36:49 -0800 | [diff] [blame] | 399 | utils::eMdpPipeType Overlay::PipeBook::pipeTypeLUT[utils::OV_MAX] = |
| 400 | {utils::OV_MDP_PIPE_ANY}; |
Naseer Ahmed | 758bfc5 | 2012-11-28 17:02:08 -0500 | [diff] [blame] | 401 | |
| 402 | }; // namespace overlay |