blob: d9baadd9e02eddfc9cd393580fca19c33f240989 [file] [log] [blame]
Naseer Ahmed29a26812012-06-14 00:56:20 -07001/*
Sushil Chauhan07a2c762013-03-06 15:36:49 -08002* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
Naseer Ahmed29a26812012-06-14 00:56:20 -07003*
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 Ahmed758bfc52012-11-28 17:02:08 -050013* * Neither the name of The Linux Foundation nor the names of its
Naseer Ahmed29a26812012-06-14 00:56:20 -070014* 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
Saurabh Shahb8f58e22013-09-26 16:20:07 -070030#include <dlfcn.h>
Naseer Ahmed29a26812012-06-14 00:56:20 -070031#include "overlay.h"
Naseer Ahmed758bfc52012-11-28 17:02:08 -050032#include "pipes/overlayGenPipe.h"
33#include "mdp_version.h"
Saurabh Shah5daeee52013-01-23 16:52:26 +080034#include "qdMetaData.h"
Naseer Ahmed29a26812012-06-14 00:56:20 -070035
Saurabh Shahb8f58e22013-09-26 16:20:07 -070036#ifdef USES_QSEED_SCALAR
37#include <scale/scale.h>
38using namespace scale;
39#endif
40
Naseer Ahmed758bfc52012-11-28 17:02:08 -050041#define PIPE_DEBUG 0
Naseer Ahmed29a26812012-06-14 00:56:20 -070042
43namespace overlay {
Naseer Ahmed758bfc52012-11-28 17:02:08 -050044using namespace utils;
Naseer Ahmed29a26812012-06-14 00:56:20 -070045
Saurabh Shahb8f58e22013-09-26 16:20:07 -070046
Naseer Ahmed758bfc52012-11-28 17:02:08 -050047Overlay::Overlay() {
Sushil Chauhan07a2c762013-03-06 15:36:49 -080048 PipeBook::NUM_PIPES = qdutils::MDPVersion::getInstance().getTotalPipes();
Naseer Ahmed758bfc52012-11-28 17:02:08 -050049 for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
50 mPipeBook[i].init();
Naseer Ahmed1ddf3662012-07-31 19:14:18 -070051 }
Naseer Ahmed1ddf3662012-07-31 19:14:18 -070052
Naseer Ahmed758bfc52012-11-28 17:02:08 -050053 mDumpStr[0] = '\0';
Saurabh Shahb8f58e22013-09-26 16:20:07 -070054 initScalar();
Raj Kamala8c065f2013-10-22 14:52:45 +053055 setDMAMultiplexingSupported();
Naseer Ahmed29a26812012-06-14 00:56:20 -070056}
57
58Overlay::~Overlay() {
Naseer Ahmed758bfc52012-11-28 17:02:08 -050059 for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
60 mPipeBook[i].destroy();
61 }
Saurabh Shahb8f58e22013-09-26 16:20:07 -070062 destroyScalar();
Naseer Ahmed29a26812012-06-14 00:56:20 -070063}
64
Naseer Ahmed758bfc52012-11-28 17:02:08 -050065void Overlay::configBegin() {
66 for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
67 //Mark as available for this round.
68 PipeBook::resetUse(i);
69 PipeBook::resetAllocation(i);
70 }
Saurabh Shah784e9852013-08-21 16:51:21 -070071 sForceSetBitmap = 0;
Naseer Ahmed758bfc52012-11-28 17:02:08 -050072 mDumpStr[0] = '\0';
Saurabh Shahb8f58e22013-09-26 16:20:07 -070073
74#ifdef USES_QSEED_SCALAR
75 Scale *scalar = getScalar();
76 if(scalar) {
77 scalar->configBegin();
78 }
79#endif
Naseer Ahmed758bfc52012-11-28 17:02:08 -050080}
81
82void Overlay::configDone() {
Naseer Ahmed758bfc52012-11-28 17:02:08 -050083 for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
84 if(PipeBook::isNotUsed(i)) {
85 //Forces UNSET on pipes, flushes rotator memory and session, closes
86 //fds
87 if(mPipeBook[i].valid()) {
88 char str[32];
Saurabh Shahaf5f5972013-07-30 13:56:35 -070089 sprintf(str, "Unset=%s dpy=%d mix=%d; ",
90 PipeBook::getDestStr((eDest)i),
91 mPipeBook[i].mDisplay, mPipeBook[i].mMixer);
Saurabh Shah9dc88fc2013-07-15 16:02:30 -070092#if PIPE_DEBUG
Naseer Ahmed758bfc52012-11-28 17:02:08 -050093 strncat(mDumpStr, str, strlen(str));
Saurabh Shah9dc88fc2013-07-15 16:02:30 -070094#endif
Naseer Ahmed758bfc52012-11-28 17:02:08 -050095 }
96 mPipeBook[i].destroy();
Naseer Ahmed1ddf3662012-07-31 19:14:18 -070097 }
Naseer Ahmed29a26812012-06-14 00:56:20 -070098 }
Naseer Ahmed758bfc52012-11-28 17:02:08 -050099 dump();
100 PipeBook::save();
Saurabh Shahb8f58e22013-09-26 16:20:07 -0700101
102#ifdef USES_QSEED_SCALAR
103 Scale *scalar = getScalar();
104 if(scalar) {
105 scalar->configDone();
106 }
107#endif
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500108}
109
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700110eDest Overlay::nextPipe(eMdpPipeType type, int dpy, int mixer) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500111 eDest dest = OV_INVALID;
112
113 for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700114 if( (type == OV_MDP_PIPE_ANY || //Pipe type match
115 type == PipeBook::getPipeType((eDest)i)) &&
116 (mPipeBook[i].mDisplay == DPY_UNUSED || //Free or same display
117 mPipeBook[i].mDisplay == dpy) &&
118 (mPipeBook[i].mMixer == MIXER_UNUSED || //Free or same mixer
119 mPipeBook[i].mMixer == mixer) &&
120 PipeBook::isNotAllocated(i) && //Free pipe
Raj Kamala8c065f2013-10-22 14:52:45 +0530121 ( (sDMAMultiplexingSupported && dpy) ||
122 !(sDMAMode == DMA_BLOCK_MODE && //DMA pipe in Line mode
123 PipeBook::getPipeType((eDest)i) == OV_MDP_PIPE_DMA)) ){
124 //DMA-Multiplexing is only supported for WB on 8x26
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700125 dest = (eDest)i;
126 PipeBook::setAllocation(i);
127 break;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500128 }
129 }
130
131 if(dest != OV_INVALID) {
132 int index = (int)dest;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500133 mPipeBook[index].mDisplay = dpy;
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700134 mPipeBook[index].mMixer = mixer;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500135 if(not mPipeBook[index].valid()) {
136 mPipeBook[index].mPipe = new GenericPipe(dpy);
137 char str[32];
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700138 snprintf(str, 32, "Set=%s dpy=%d mix=%d; ",
139 PipeBook::getDestStr(dest), dpy, mixer);
Saurabh Shah9dc88fc2013-07-15 16:02:30 -0700140#if PIPE_DEBUG
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500141 strncat(mDumpStr, str, strlen(str));
Saurabh Shah9dc88fc2013-07-15 16:02:30 -0700142#endif
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500143 }
144 } else {
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700145 ALOGD_IF(PIPE_DEBUG, "Pipe unavailable type=%d display=%d mixer=%d",
146 (int)type, dpy, mixer);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500147 }
148
149 return dest;
150}
151
Saurabh Shah0ceeb6a2013-04-23 10:46:07 -0700152bool Overlay::isPipeTypeAttached(eMdpPipeType type) {
153 for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
154 if(type == PipeBook::getPipeType((eDest)i) &&
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700155 mPipeBook[i].mDisplay != DPY_UNUSED) {
Saurabh Shah0ceeb6a2013-04-23 10:46:07 -0700156 return true;
157 }
158 }
159 return false;
160}
161
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500162bool Overlay::commit(utils::eDest dest) {
163 bool ret = false;
164 int index = (int)dest;
165 validate(index);
166
167 if(mPipeBook[index].mPipe->commit()) {
168 ret = true;
169 PipeBook::setUse((int)dest);
Saurabh Shah784e9852013-08-21 16:51:21 -0700170 if(sForceSetBitmap & (1 << mPipeBook[index].mDisplay)) {
171 mPipeBook[index].mPipe->forceSet();
172 }
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500173 } else {
Sushil Chauhane0dff932013-03-01 14:33:18 -0800174 int dpy = mPipeBook[index].mDisplay;
175 for(int i = 0; i < PipeBook::NUM_PIPES; i++)
Saurabh Shahdf0be752013-05-23 14:40:00 -0700176 if (mPipeBook[i].mDisplay == dpy) {
Sushil Chauhane0dff932013-03-01 14:33:18 -0800177 PipeBook::resetAllocation(i);
Saurabh Shahdf0be752013-05-23 14:40:00 -0700178 PipeBook::resetUse(i);
179 if(mPipeBook[i].valid()) {
180 mPipeBook[i].mPipe->forceSet();
181 }
182 }
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500183 }
184 return ret;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700185}
186
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700187bool Overlay::queueBuffer(int fd, uint32_t offset,
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500188 utils::eDest dest) {
189 int index = (int)dest;
190 bool ret = false;
191 validate(index);
192 //Queue only if commit() has succeeded (and the bit set)
193 if(PipeBook::isUsed((int)dest)) {
194 ret = mPipeBook[index].mPipe->queueBuffer(fd, offset);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700195 }
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500196 return ret;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700197}
198
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500199void Overlay::setCrop(const utils::Dim& d,
200 utils::eDest dest) {
201 int index = (int)dest;
202 validate(index);
203 mPipeBook[index].mPipe->setCrop(d);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700204}
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700205
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500206void Overlay::setPosition(const utils::Dim& d,
207 utils::eDest dest) {
208 int index = (int)dest;
209 validate(index);
210 mPipeBook[index].mPipe->setPosition(d);
211}
212
213void Overlay::setTransform(const int orient,
214 utils::eDest dest) {
215 int index = (int)dest;
216 validate(index);
217
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700218 utils::eTransform transform =
219 static_cast<utils::eTransform>(orient);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500220 mPipeBook[index].mPipe->setTransform(transform);
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700221
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500222}
223
224void Overlay::setSource(const utils::PipeArgs args,
225 utils::eDest dest) {
226 int index = (int)dest;
227 validate(index);
228
229 PipeArgs newArgs(args);
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800230 if(PipeBook::getPipeType(dest) == OV_MDP_PIPE_VG) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500231 setMdpFlags(newArgs.mdpFlags, OV_MDP_PIPE_SHARE);
232 } else {
233 clearMdpFlags(newArgs.mdpFlags, OV_MDP_PIPE_SHARE);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700234 }
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800235
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800236 if(PipeBook::getPipeType(dest) == OV_MDP_PIPE_DMA) {
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800237 setMdpFlags(newArgs.mdpFlags, OV_MDP_PIPE_FORCE_DMA);
238 } else {
239 clearMdpFlags(newArgs.mdpFlags, OV_MDP_PIPE_FORCE_DMA);
240 }
241
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500242 mPipeBook[index].mPipe->setSource(newArgs);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700243}
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700244
Saurabh Shah5daeee52013-01-23 16:52:26 +0800245void Overlay::setVisualParams(const MetaData_t& metadata, utils::eDest dest) {
246 int index = (int)dest;
247 validate(index);
248 mPipeBook[index].mPipe->setVisualParams(metadata);
249}
250
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500251Overlay* Overlay::getInstance() {
252 if(sInstance == NULL) {
253 sInstance = new Overlay();
Naseer Ahmed29a26812012-06-14 00:56:20 -0700254 }
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500255 return sInstance;
Saurabh Shahc4d034f2012-09-27 15:55:15 -0700256}
257
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800258// Clears any VG pipes allocated to the fb devices
259// Generates a LUT for pipe types.
260int Overlay::initOverlay() {
261 int mdpVersion = qdutils::MDPVersion::getInstance().getMDPVersion();
262 int numPipesXType[OV_MDP_PIPE_ANY] = {0};
263 numPipesXType[OV_MDP_PIPE_RGB] =
264 qdutils::MDPVersion::getInstance().getRGBPipes();
265 numPipesXType[OV_MDP_PIPE_VG] =
266 qdutils::MDPVersion::getInstance().getVGPipes();
267 numPipesXType[OV_MDP_PIPE_DMA] =
268 qdutils::MDPVersion::getInstance().getDMAPipes();
269
270 int index = 0;
271 for(int X = 0; X < (int)OV_MDP_PIPE_ANY; X++) { //iterate over types
272 for(int j = 0; j < numPipesXType[X]; j++) { //iterate over num
273 PipeBook::pipeTypeLUT[index] = (utils::eMdpPipeType)X;
274 index++;
275 }
Saurabh Shahc4d034f2012-09-27 15:55:15 -0700276 }
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800277
Xiaoming Zhou5eff8b62013-05-01 20:56:09 -0400278 if (mdpVersion < qdutils::MDSS_V5 && mdpVersion != qdutils::MDP_V3_0_4) {
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800279 msmfb_mixer_info_req req;
280 mdp_mixer_info *minfo = NULL;
281 char name[64];
282 int fd = -1;
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700283 for(int i = 0; i < MAX_FB_DEVICES; i++) {
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800284 snprintf(name, 64, FB_DEVICE_TEMPLATE, i);
285 ALOGD("initoverlay:: opening the device:: %s", name);
286 fd = ::open(name, O_RDWR, 0);
287 if(fd < 0) {
288 ALOGE("cannot open framebuffer(%d)", i);
289 return -1;
290 }
291 //Get the mixer configuration */
292 req.mixer_num = i;
293 if (ioctl(fd, MSMFB_MIXER_INFO, &req) == -1) {
294 ALOGE("ERROR: MSMFB_MIXER_INFO ioctl failed");
295 close(fd);
296 return -1;
297 }
298 minfo = req.info;
299 for (int j = 0; j < req.cnt; j++) {
300 ALOGD("ndx=%d num=%d z_order=%d", minfo->pndx, minfo->pnum,
301 minfo->z_order);
302 // except the RGB base layer with z_order of -1, clear any
303 // other pipes connected to mixer.
304 if((minfo->z_order) != -1) {
305 int index = minfo->pndx;
306 ALOGD("Unset overlay with index: %d at mixer %d", index, i);
307 if(ioctl(fd, MSMFB_OVERLAY_UNSET, &index) == -1) {
308 ALOGE("ERROR: MSMFB_OVERLAY_UNSET failed");
309 close(fd);
310 return -1;
311 }
312 }
313 minfo++;
314 }
315 close(fd);
316 fd = -1;
317 }
318 }
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700319
320 FILE *displayDeviceFP = NULL;
321 const int MAX_FRAME_BUFFER_NAME_SIZE = 128;
322 char fbType[MAX_FRAME_BUFFER_NAME_SIZE];
323 char msmFbTypePath[MAX_FRAME_BUFFER_NAME_SIZE];
324 const char *strDtvPanel = "dtv panel";
325 const char *strWbPanel = "writeback panel";
326
327 for(int num = 1; num < MAX_FB_DEVICES; num++) {
328 snprintf (msmFbTypePath, sizeof(msmFbTypePath),
329 "/sys/class/graphics/fb%d/msm_fb_type", num);
330 displayDeviceFP = fopen(msmFbTypePath, "r");
331
332 if(displayDeviceFP){
333 fread(fbType, sizeof(char), MAX_FRAME_BUFFER_NAME_SIZE,
334 displayDeviceFP);
335
336 if(strncmp(fbType, strDtvPanel, strlen(strDtvPanel)) == 0) {
337 sDpyFbMap[DPY_EXTERNAL] = num;
338 } else if(strncmp(fbType, strWbPanel, strlen(strWbPanel)) == 0) {
339 sDpyFbMap[DPY_WRITEBACK] = num;
340 }
341
342 fclose(displayDeviceFP);
343 }
344 }
345
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800346 return 0;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700347}
348
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700349bool Overlay::displayCommit(const int& fd) {
Jeykumar Sankaran6a9bb9e2013-08-01 14:19:26 -0700350 utils::Dim roi;
351 return displayCommit(fd, roi);
352}
353
354bool Overlay::displayCommit(const int& fd, const utils::Dim& roi) {
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700355 //Commit
356 struct mdp_display_commit info;
357 memset(&info, 0, sizeof(struct mdp_display_commit));
358 info.flags = MDP_DISPLAY_COMMIT_OVERLAY;
Jeykumar Sankaran6a9bb9e2013-08-01 14:19:26 -0700359 info.roi.x = roi.x;
360 info.roi.y = roi.y;
361 info.roi.w = roi.w;
362 info.roi.h = roi.h;
363
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700364 if(!mdp_wrapper::displayCommit(fd, info)) {
Jeykumar Sankaran6a9bb9e2013-08-01 14:19:26 -0700365 ALOGE("%s: commit failed", __func__);
366 return false;
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700367 }
368 return true;
369}
370
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500371void Overlay::dump() const {
Saurabh Shah9dc88fc2013-07-15 16:02:30 -0700372#if PIPE_DEBUG
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500373 if(strlen(mDumpStr)) { //dump only on state change
Saurabh Shah9dc88fc2013-07-15 16:02:30 -0700374 ALOGD("%s\n", mDumpStr);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500375 }
Saurabh Shah9dc88fc2013-07-15 16:02:30 -0700376#endif
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500377}
378
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800379void Overlay::getDump(char *buf, size_t len) {
380 int totalPipes = 0;
Saurabh Shahae61b2b2013-04-10 16:37:25 -0700381 const char *str = "\nOverlay State\n\n";
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800382 strncat(buf, str, strlen(str));
383 for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
384 if(mPipeBook[i].valid()) {
385 mPipeBook[i].mPipe->getDump(buf, len);
386 char str[64] = {'\0'};
Saurabh Shahae61b2b2013-04-10 16:37:25 -0700387 snprintf(str, 64, "Display=%d\n\n", mPipeBook[i].mDisplay);
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800388 strncat(buf, str, strlen(str));
389 totalPipes++;
390 }
391 }
392 char str_pipes[64] = {'\0'};
Saurabh Shahae61b2b2013-04-10 16:37:25 -0700393 snprintf(str_pipes, 64, "Pipes=%d\n\n", totalPipes);
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800394 strncat(buf, str_pipes, strlen(str_pipes));
395}
396
Sushil Chauhanbd3ea922013-05-15 12:25:26 -0700397void Overlay::clear(int dpy) {
398 for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
399 if (mPipeBook[i].mDisplay == dpy) {
400 // Mark as available for this round
401 PipeBook::resetUse(i);
402 PipeBook::resetAllocation(i);
Saurabh Shahdf0be752013-05-23 14:40:00 -0700403 if(mPipeBook[i].valid()) {
404 mPipeBook[i].mPipe->forceSet();
405 }
Sushil Chauhanbd3ea922013-05-15 12:25:26 -0700406 }
407 }
408}
409
Saurabh Shahb8f58e22013-09-26 16:20:07 -0700410void Overlay::initScalar() {
411#ifdef USES_QSEED_SCALAR
412 if(sLibScaleHandle == NULL) {
413 sLibScaleHandle = dlopen("libscale.so", RTLD_NOW);
414 }
415
416 if(sLibScaleHandle) {
417 if(sScale == NULL) {
418 Scale* (*getInstance)();
419 *(void **) &getInstance = dlsym(sLibScaleHandle, "getInstance");
420 if(getInstance) {
421 sScale = getInstance();
422 }
423 }
424 }
425#endif
426}
427
428void Overlay::destroyScalar() {
429#ifdef USES_QSEED_SCALAR
430 if(sLibScaleHandle) {
431 if(sScale) {
432 void (*destroyInstance)(Scale*);
433 *(void **) &destroyInstance = dlsym(sLibScaleHandle,
434 "destroyInstance");
435 if(destroyInstance) {
436 destroyInstance(sScale);
437 sScale = NULL;
438 }
439 }
440 dlclose(sLibScaleHandle);
441 sLibScaleHandle = NULL;
442 }
443#endif
444}
445
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500446void Overlay::PipeBook::init() {
447 mPipe = NULL;
448 mDisplay = DPY_UNUSED;
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700449 mMixer = MIXER_UNUSED;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500450}
451
452void Overlay::PipeBook::destroy() {
453 if(mPipe) {
454 delete mPipe;
455 mPipe = NULL;
456 }
457 mDisplay = DPY_UNUSED;
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700458 mMixer = MIXER_UNUSED;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500459}
460
461Overlay* Overlay::sInstance = 0;
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700462int Overlay::sDpyFbMap[DPY_MAX] = {0, -1, -1};
Saurabh Shah85234ec2013-04-12 17:09:00 -0700463int Overlay::sDMAMode = DMA_LINE_MODE;
Raj Kamala8c065f2013-10-22 14:52:45 +0530464bool Overlay::sDMAMultiplexingSupported = false;
Saurabh Shah784e9852013-08-21 16:51:21 -0700465int Overlay::sForceSetBitmap = 0;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500466int Overlay::PipeBook::NUM_PIPES = 0;
467int Overlay::PipeBook::sPipeUsageBitmap = 0;
468int Overlay::PipeBook::sLastUsageBitmap = 0;
469int Overlay::PipeBook::sAllocatedBitmap = 0;
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800470utils::eMdpPipeType Overlay::PipeBook::pipeTypeLUT[utils::OV_MAX] =
471 {utils::OV_MDP_PIPE_ANY};
Saurabh Shahb8f58e22013-09-26 16:20:07 -0700472void *Overlay::sLibScaleHandle = NULL;
473scale::Scale *Overlay::sScale = NULL;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500474
475}; // namespace overlay