blob: 6784d4f8195ec118030a27610773e1b396395d36 [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();
Naseer Ahmed29a26812012-06-14 00:56:20 -070055}
56
57Overlay::~Overlay() {
Naseer Ahmed758bfc52012-11-28 17:02:08 -050058 for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
59 mPipeBook[i].destroy();
60 }
Saurabh Shahb8f58e22013-09-26 16:20:07 -070061 destroyScalar();
Naseer Ahmed29a26812012-06-14 00:56:20 -070062}
63
Naseer Ahmed758bfc52012-11-28 17:02:08 -050064void Overlay::configBegin() {
65 for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
66 //Mark as available for this round.
67 PipeBook::resetUse(i);
68 PipeBook::resetAllocation(i);
69 }
Saurabh Shah784e9852013-08-21 16:51:21 -070070 sForceSetBitmap = 0;
Naseer Ahmed758bfc52012-11-28 17:02:08 -050071 mDumpStr[0] = '\0';
Saurabh Shahb8f58e22013-09-26 16:20:07 -070072
73#ifdef USES_QSEED_SCALAR
74 Scale *scalar = getScalar();
75 if(scalar) {
76 scalar->configBegin();
77 }
78#endif
Naseer Ahmed758bfc52012-11-28 17:02:08 -050079}
80
81void Overlay::configDone() {
Naseer Ahmed758bfc52012-11-28 17:02:08 -050082 for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
Zohaib Alam4b0a9242013-11-20 23:54:12 -050083 if((PipeBook::isNotUsed(i) && !sessionInProgress((eDest)i)) ||
84 isSessionEnded((eDest)i)) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -050085 //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
Zohaib Alam4b0a9242013-11-20 23:54:12 -0500110int Overlay::getPipeId(utils::eDest dest) {
111 return mPipeBook[(int)dest].mPipe->getPipeId();
112}
113
114eDest Overlay::getDest(int pipeid) {
115 eDest dest = OV_INVALID;
116 // finding the dest corresponding to the given pipe
117 for(int i=0; i < PipeBook::NUM_PIPES; ++i) {
118 if(mPipeBook[i].valid() && mPipeBook[i].mPipe->getPipeId() == pipeid) {
119 return (eDest)i;
120 }
121 }
122 return dest;
123}
124
125eDest Overlay::reservePipe(int pipeid) {
126 eDest dest = getDest(pipeid);
127 PipeBook::setAllocation((int)dest);
128 return dest;
129}
130
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700131eDest Overlay::nextPipe(eMdpPipeType type, int dpy, int mixer) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500132 eDest dest = OV_INVALID;
133
134 for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700135 if( (type == OV_MDP_PIPE_ANY || //Pipe type match
136 type == PipeBook::getPipeType((eDest)i)) &&
137 (mPipeBook[i].mDisplay == DPY_UNUSED || //Free or same display
138 mPipeBook[i].mDisplay == dpy) &&
139 (mPipeBook[i].mMixer == MIXER_UNUSED || //Free or same mixer
140 mPipeBook[i].mMixer == mixer) &&
141 PipeBook::isNotAllocated(i) && //Free pipe
142 !(sDMAMode == DMA_BLOCK_MODE && //DMA pipe in Line mode
143 PipeBook::getPipeType((eDest)i) == OV_MDP_PIPE_DMA)) {
144 dest = (eDest)i;
145 PipeBook::setAllocation(i);
146 break;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500147 }
148 }
149
150 if(dest != OV_INVALID) {
151 int index = (int)dest;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500152 mPipeBook[index].mDisplay = dpy;
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700153 mPipeBook[index].mMixer = mixer;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500154 if(not mPipeBook[index].valid()) {
155 mPipeBook[index].mPipe = new GenericPipe(dpy);
Zohaib Alam4b0a9242013-11-20 23:54:12 -0500156 mPipeBook[index].mSession = PipeBook::NONE;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500157 char str[32];
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700158 snprintf(str, 32, "Set=%s dpy=%d mix=%d; ",
159 PipeBook::getDestStr(dest), dpy, mixer);
Saurabh Shah9dc88fc2013-07-15 16:02:30 -0700160#if PIPE_DEBUG
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500161 strncat(mDumpStr, str, strlen(str));
Saurabh Shah9dc88fc2013-07-15 16:02:30 -0700162#endif
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500163 }
164 } else {
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700165 ALOGD_IF(PIPE_DEBUG, "Pipe unavailable type=%d display=%d mixer=%d",
166 (int)type, dpy, mixer);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500167 }
168
169 return dest;
170}
171
Zohaib Alam4b0a9242013-11-20 23:54:12 -0500172void Overlay::endAllSessions() {
173 for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
174 if(mPipeBook[i].valid() && mPipeBook[i].mSession==PipeBook::START)
175 mPipeBook[i].mSession = PipeBook::END;
176 }
177}
178
Saurabh Shah0ceeb6a2013-04-23 10:46:07 -0700179bool Overlay::isPipeTypeAttached(eMdpPipeType type) {
180 for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
181 if(type == PipeBook::getPipeType((eDest)i) &&
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700182 mPipeBook[i].mDisplay != DPY_UNUSED) {
Saurabh Shah0ceeb6a2013-04-23 10:46:07 -0700183 return true;
184 }
185 }
186 return false;
187}
188
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500189bool Overlay::commit(utils::eDest dest) {
190 bool ret = false;
191 int index = (int)dest;
192 validate(index);
193
194 if(mPipeBook[index].mPipe->commit()) {
195 ret = true;
196 PipeBook::setUse((int)dest);
Saurabh Shah784e9852013-08-21 16:51:21 -0700197 if(sForceSetBitmap & (1 << mPipeBook[index].mDisplay)) {
198 mPipeBook[index].mPipe->forceSet();
199 }
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500200 } else {
Sushil Chauhane0dff932013-03-01 14:33:18 -0800201 int dpy = mPipeBook[index].mDisplay;
202 for(int i = 0; i < PipeBook::NUM_PIPES; i++)
Saurabh Shahdf0be752013-05-23 14:40:00 -0700203 if (mPipeBook[i].mDisplay == dpy) {
Sushil Chauhane0dff932013-03-01 14:33:18 -0800204 PipeBook::resetAllocation(i);
Saurabh Shahdf0be752013-05-23 14:40:00 -0700205 PipeBook::resetUse(i);
206 if(mPipeBook[i].valid()) {
207 mPipeBook[i].mPipe->forceSet();
208 }
209 }
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500210 }
211 return ret;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700212}
213
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700214bool Overlay::queueBuffer(int fd, uint32_t offset,
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500215 utils::eDest dest) {
216 int index = (int)dest;
217 bool ret = false;
218 validate(index);
219 //Queue only if commit() has succeeded (and the bit set)
220 if(PipeBook::isUsed((int)dest)) {
221 ret = mPipeBook[index].mPipe->queueBuffer(fd, offset);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700222 }
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500223 return ret;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700224}
225
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500226void Overlay::setCrop(const utils::Dim& d,
227 utils::eDest dest) {
228 int index = (int)dest;
229 validate(index);
230 mPipeBook[index].mPipe->setCrop(d);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700231}
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700232
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500233void Overlay::setPosition(const utils::Dim& d,
234 utils::eDest dest) {
235 int index = (int)dest;
236 validate(index);
237 mPipeBook[index].mPipe->setPosition(d);
238}
239
240void Overlay::setTransform(const int orient,
241 utils::eDest dest) {
242 int index = (int)dest;
243 validate(index);
244
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700245 utils::eTransform transform =
246 static_cast<utils::eTransform>(orient);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500247 mPipeBook[index].mPipe->setTransform(transform);
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700248
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500249}
250
251void Overlay::setSource(const utils::PipeArgs args,
252 utils::eDest dest) {
253 int index = (int)dest;
254 validate(index);
255
256 PipeArgs newArgs(args);
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800257 if(PipeBook::getPipeType(dest) == OV_MDP_PIPE_VG) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500258 setMdpFlags(newArgs.mdpFlags, OV_MDP_PIPE_SHARE);
259 } else {
260 clearMdpFlags(newArgs.mdpFlags, OV_MDP_PIPE_SHARE);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700261 }
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800262
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800263 if(PipeBook::getPipeType(dest) == OV_MDP_PIPE_DMA) {
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800264 setMdpFlags(newArgs.mdpFlags, OV_MDP_PIPE_FORCE_DMA);
265 } else {
266 clearMdpFlags(newArgs.mdpFlags, OV_MDP_PIPE_FORCE_DMA);
267 }
268
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500269 mPipeBook[index].mPipe->setSource(newArgs);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700270}
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700271
Saurabh Shah5daeee52013-01-23 16:52:26 +0800272void Overlay::setVisualParams(const MetaData_t& metadata, utils::eDest dest) {
273 int index = (int)dest;
274 validate(index);
275 mPipeBook[index].mPipe->setVisualParams(metadata);
276}
277
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500278Overlay* Overlay::getInstance() {
279 if(sInstance == NULL) {
280 sInstance = new Overlay();
Naseer Ahmed29a26812012-06-14 00:56:20 -0700281 }
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500282 return sInstance;
Saurabh Shahc4d034f2012-09-27 15:55:15 -0700283}
284
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800285// Clears any VG pipes allocated to the fb devices
286// Generates a LUT for pipe types.
287int Overlay::initOverlay() {
288 int mdpVersion = qdutils::MDPVersion::getInstance().getMDPVersion();
289 int numPipesXType[OV_MDP_PIPE_ANY] = {0};
290 numPipesXType[OV_MDP_PIPE_RGB] =
291 qdutils::MDPVersion::getInstance().getRGBPipes();
292 numPipesXType[OV_MDP_PIPE_VG] =
293 qdutils::MDPVersion::getInstance().getVGPipes();
294 numPipesXType[OV_MDP_PIPE_DMA] =
295 qdutils::MDPVersion::getInstance().getDMAPipes();
296
297 int index = 0;
298 for(int X = 0; X < (int)OV_MDP_PIPE_ANY; X++) { //iterate over types
299 for(int j = 0; j < numPipesXType[X]; j++) { //iterate over num
300 PipeBook::pipeTypeLUT[index] = (utils::eMdpPipeType)X;
301 index++;
302 }
Saurabh Shahc4d034f2012-09-27 15:55:15 -0700303 }
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800304
Xiaoming Zhou5eff8b62013-05-01 20:56:09 -0400305 if (mdpVersion < qdutils::MDSS_V5 && mdpVersion != qdutils::MDP_V3_0_4) {
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800306 msmfb_mixer_info_req req;
307 mdp_mixer_info *minfo = NULL;
308 char name[64];
309 int fd = -1;
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700310 for(int i = 0; i < MAX_FB_DEVICES; i++) {
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800311 snprintf(name, 64, FB_DEVICE_TEMPLATE, i);
312 ALOGD("initoverlay:: opening the device:: %s", name);
313 fd = ::open(name, O_RDWR, 0);
314 if(fd < 0) {
315 ALOGE("cannot open framebuffer(%d)", i);
316 return -1;
317 }
318 //Get the mixer configuration */
319 req.mixer_num = i;
320 if (ioctl(fd, MSMFB_MIXER_INFO, &req) == -1) {
321 ALOGE("ERROR: MSMFB_MIXER_INFO ioctl failed");
322 close(fd);
323 return -1;
324 }
325 minfo = req.info;
326 for (int j = 0; j < req.cnt; j++) {
327 ALOGD("ndx=%d num=%d z_order=%d", minfo->pndx, minfo->pnum,
328 minfo->z_order);
329 // except the RGB base layer with z_order of -1, clear any
330 // other pipes connected to mixer.
331 if((minfo->z_order) != -1) {
332 int index = minfo->pndx;
333 ALOGD("Unset overlay with index: %d at mixer %d", index, i);
334 if(ioctl(fd, MSMFB_OVERLAY_UNSET, &index) == -1) {
335 ALOGE("ERROR: MSMFB_OVERLAY_UNSET failed");
336 close(fd);
337 return -1;
338 }
339 }
340 minfo++;
341 }
342 close(fd);
343 fd = -1;
344 }
345 }
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700346
347 FILE *displayDeviceFP = NULL;
348 const int MAX_FRAME_BUFFER_NAME_SIZE = 128;
349 char fbType[MAX_FRAME_BUFFER_NAME_SIZE];
350 char msmFbTypePath[MAX_FRAME_BUFFER_NAME_SIZE];
351 const char *strDtvPanel = "dtv panel";
352 const char *strWbPanel = "writeback panel";
353
354 for(int num = 1; num < MAX_FB_DEVICES; num++) {
355 snprintf (msmFbTypePath, sizeof(msmFbTypePath),
356 "/sys/class/graphics/fb%d/msm_fb_type", num);
357 displayDeviceFP = fopen(msmFbTypePath, "r");
358
359 if(displayDeviceFP){
360 fread(fbType, sizeof(char), MAX_FRAME_BUFFER_NAME_SIZE,
361 displayDeviceFP);
362
363 if(strncmp(fbType, strDtvPanel, strlen(strDtvPanel)) == 0) {
364 sDpyFbMap[DPY_EXTERNAL] = num;
365 } else if(strncmp(fbType, strWbPanel, strlen(strWbPanel)) == 0) {
366 sDpyFbMap[DPY_WRITEBACK] = num;
367 }
368
369 fclose(displayDeviceFP);
370 }
371 }
372
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800373 return 0;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700374}
375
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700376bool Overlay::displayCommit(const int& fd) {
Jeykumar Sankaran6a9bb9e2013-08-01 14:19:26 -0700377 utils::Dim roi;
378 return displayCommit(fd, roi);
379}
380
381bool Overlay::displayCommit(const int& fd, const utils::Dim& roi) {
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700382 //Commit
383 struct mdp_display_commit info;
384 memset(&info, 0, sizeof(struct mdp_display_commit));
385 info.flags = MDP_DISPLAY_COMMIT_OVERLAY;
Jeykumar Sankaran6a9bb9e2013-08-01 14:19:26 -0700386 info.roi.x = roi.x;
387 info.roi.y = roi.y;
388 info.roi.w = roi.w;
389 info.roi.h = roi.h;
390
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700391 if(!mdp_wrapper::displayCommit(fd, info)) {
Jeykumar Sankaran6a9bb9e2013-08-01 14:19:26 -0700392 ALOGE("%s: commit failed", __func__);
393 return false;
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700394 }
395 return true;
396}
397
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500398void Overlay::dump() const {
Saurabh Shah9dc88fc2013-07-15 16:02:30 -0700399#if PIPE_DEBUG
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500400 if(strlen(mDumpStr)) { //dump only on state change
Saurabh Shah9dc88fc2013-07-15 16:02:30 -0700401 ALOGD("%s\n", mDumpStr);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500402 }
Saurabh Shah9dc88fc2013-07-15 16:02:30 -0700403#endif
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500404}
405
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800406void Overlay::getDump(char *buf, size_t len) {
407 int totalPipes = 0;
Saurabh Shahae61b2b2013-04-10 16:37:25 -0700408 const char *str = "\nOverlay State\n\n";
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800409 strncat(buf, str, strlen(str));
410 for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
411 if(mPipeBook[i].valid()) {
412 mPipeBook[i].mPipe->getDump(buf, len);
413 char str[64] = {'\0'};
Saurabh Shahae61b2b2013-04-10 16:37:25 -0700414 snprintf(str, 64, "Display=%d\n\n", mPipeBook[i].mDisplay);
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800415 strncat(buf, str, strlen(str));
416 totalPipes++;
417 }
418 }
419 char str_pipes[64] = {'\0'};
Saurabh Shahae61b2b2013-04-10 16:37:25 -0700420 snprintf(str_pipes, 64, "Pipes=%d\n\n", totalPipes);
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800421 strncat(buf, str_pipes, strlen(str_pipes));
422}
423
Sushil Chauhanbd3ea922013-05-15 12:25:26 -0700424void Overlay::clear(int dpy) {
425 for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
426 if (mPipeBook[i].mDisplay == dpy) {
427 // Mark as available for this round
428 PipeBook::resetUse(i);
429 PipeBook::resetAllocation(i);
Saurabh Shahdf0be752013-05-23 14:40:00 -0700430 if(mPipeBook[i].valid()) {
431 mPipeBook[i].mPipe->forceSet();
432 }
Sushil Chauhanbd3ea922013-05-15 12:25:26 -0700433 }
434 }
435}
436
Saurabh Shahb8f58e22013-09-26 16:20:07 -0700437void Overlay::initScalar() {
438#ifdef USES_QSEED_SCALAR
439 if(sLibScaleHandle == NULL) {
440 sLibScaleHandle = dlopen("libscale.so", RTLD_NOW);
441 }
442
443 if(sLibScaleHandle) {
444 if(sScale == NULL) {
445 Scale* (*getInstance)();
446 *(void **) &getInstance = dlsym(sLibScaleHandle, "getInstance");
447 if(getInstance) {
448 sScale = getInstance();
449 }
450 }
451 }
452#endif
453}
454
455void Overlay::destroyScalar() {
456#ifdef USES_QSEED_SCALAR
457 if(sLibScaleHandle) {
458 if(sScale) {
459 void (*destroyInstance)(Scale*);
460 *(void **) &destroyInstance = dlsym(sLibScaleHandle,
461 "destroyInstance");
462 if(destroyInstance) {
463 destroyInstance(sScale);
464 sScale = NULL;
465 }
466 }
467 dlclose(sLibScaleHandle);
468 sLibScaleHandle = NULL;
469 }
470#endif
471}
472
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500473void Overlay::PipeBook::init() {
474 mPipe = NULL;
475 mDisplay = DPY_UNUSED;
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700476 mMixer = MIXER_UNUSED;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500477}
478
479void Overlay::PipeBook::destroy() {
480 if(mPipe) {
481 delete mPipe;
482 mPipe = NULL;
483 }
484 mDisplay = DPY_UNUSED;
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700485 mMixer = MIXER_UNUSED;
Zohaib Alam4b0a9242013-11-20 23:54:12 -0500486 mSession = NONE;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500487}
488
489Overlay* Overlay::sInstance = 0;
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700490int Overlay::sDpyFbMap[DPY_MAX] = {0, -1, -1};
Saurabh Shah85234ec2013-04-12 17:09:00 -0700491int Overlay::sDMAMode = DMA_LINE_MODE;
Saurabh Shah784e9852013-08-21 16:51:21 -0700492int Overlay::sForceSetBitmap = 0;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500493int Overlay::PipeBook::NUM_PIPES = 0;
494int Overlay::PipeBook::sPipeUsageBitmap = 0;
495int Overlay::PipeBook::sLastUsageBitmap = 0;
496int Overlay::PipeBook::sAllocatedBitmap = 0;
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800497utils::eMdpPipeType Overlay::PipeBook::pipeTypeLUT[utils::OV_MAX] =
498 {utils::OV_MDP_PIPE_ANY};
Saurabh Shahb8f58e22013-09-26 16:20:07 -0700499void *Overlay::sLibScaleHandle = NULL;
500scale::Scale *Overlay::sScale = NULL;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500501
502}; // namespace overlay