blob: 9222af599d52d1f9e37a96a9629d91a7142736aa [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++) {
83 if(PipeBook::isNotUsed(i)) {
84 //Forces UNSET on pipes, flushes rotator memory and session, closes
85 //fds
86 if(mPipeBook[i].valid()) {
87 char str[32];
Saurabh Shahaf5f5972013-07-30 13:56:35 -070088 sprintf(str, "Unset=%s dpy=%d mix=%d; ",
89 PipeBook::getDestStr((eDest)i),
90 mPipeBook[i].mDisplay, mPipeBook[i].mMixer);
Saurabh Shah9dc88fc2013-07-15 16:02:30 -070091#if PIPE_DEBUG
Naseer Ahmed758bfc52012-11-28 17:02:08 -050092 strncat(mDumpStr, str, strlen(str));
Saurabh Shah9dc88fc2013-07-15 16:02:30 -070093#endif
Naseer Ahmed758bfc52012-11-28 17:02:08 -050094 }
95 mPipeBook[i].destroy();
Naseer Ahmed1ddf3662012-07-31 19:14:18 -070096 }
Naseer Ahmed29a26812012-06-14 00:56:20 -070097 }
Naseer Ahmed758bfc52012-11-28 17:02:08 -050098 dump();
99 PipeBook::save();
Saurabh Shahb8f58e22013-09-26 16:20:07 -0700100
101#ifdef USES_QSEED_SCALAR
102 Scale *scalar = getScalar();
103 if(scalar) {
104 scalar->configDone();
105 }
106#endif
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500107}
108
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700109eDest Overlay::nextPipe(eMdpPipeType type, int dpy, int mixer) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500110 eDest dest = OV_INVALID;
111
112 for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700113 if( (type == OV_MDP_PIPE_ANY || //Pipe type match
114 type == PipeBook::getPipeType((eDest)i)) &&
115 (mPipeBook[i].mDisplay == DPY_UNUSED || //Free or same display
116 mPipeBook[i].mDisplay == dpy) &&
117 (mPipeBook[i].mMixer == MIXER_UNUSED || //Free or same mixer
118 mPipeBook[i].mMixer == mixer) &&
119 PipeBook::isNotAllocated(i) && //Free pipe
120 !(sDMAMode == DMA_BLOCK_MODE && //DMA pipe in Line mode
121 PipeBook::getPipeType((eDest)i) == OV_MDP_PIPE_DMA)) {
122 dest = (eDest)i;
123 PipeBook::setAllocation(i);
124 break;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500125 }
126 }
127
128 if(dest != OV_INVALID) {
129 int index = (int)dest;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500130 mPipeBook[index].mDisplay = dpy;
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700131 mPipeBook[index].mMixer = mixer;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500132 if(not mPipeBook[index].valid()) {
133 mPipeBook[index].mPipe = new GenericPipe(dpy);
134 char str[32];
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700135 snprintf(str, 32, "Set=%s dpy=%d mix=%d; ",
136 PipeBook::getDestStr(dest), dpy, mixer);
Saurabh Shah9dc88fc2013-07-15 16:02:30 -0700137#if PIPE_DEBUG
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500138 strncat(mDumpStr, str, strlen(str));
Saurabh Shah9dc88fc2013-07-15 16:02:30 -0700139#endif
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500140 }
141 } else {
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700142 ALOGD_IF(PIPE_DEBUG, "Pipe unavailable type=%d display=%d mixer=%d",
143 (int)type, dpy, mixer);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500144 }
145
146 return dest;
147}
148
Saurabh Shah0ceeb6a2013-04-23 10:46:07 -0700149bool Overlay::isPipeTypeAttached(eMdpPipeType type) {
150 for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
151 if(type == PipeBook::getPipeType((eDest)i) &&
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700152 mPipeBook[i].mDisplay != DPY_UNUSED) {
Saurabh Shah0ceeb6a2013-04-23 10:46:07 -0700153 return true;
154 }
155 }
156 return false;
157}
158
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500159bool Overlay::commit(utils::eDest dest) {
160 bool ret = false;
161 int index = (int)dest;
162 validate(index);
163
164 if(mPipeBook[index].mPipe->commit()) {
165 ret = true;
166 PipeBook::setUse((int)dest);
Saurabh Shah784e9852013-08-21 16:51:21 -0700167 if(sForceSetBitmap & (1 << mPipeBook[index].mDisplay)) {
168 mPipeBook[index].mPipe->forceSet();
169 }
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500170 } else {
Sushil Chauhane0dff932013-03-01 14:33:18 -0800171 int dpy = mPipeBook[index].mDisplay;
172 for(int i = 0; i < PipeBook::NUM_PIPES; i++)
Saurabh Shahdf0be752013-05-23 14:40:00 -0700173 if (mPipeBook[i].mDisplay == dpy) {
Sushil Chauhane0dff932013-03-01 14:33:18 -0800174 PipeBook::resetAllocation(i);
Saurabh Shahdf0be752013-05-23 14:40:00 -0700175 PipeBook::resetUse(i);
176 if(mPipeBook[i].valid()) {
177 mPipeBook[i].mPipe->forceSet();
178 }
179 }
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500180 }
181 return ret;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700182}
183
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700184bool Overlay::queueBuffer(int fd, uint32_t offset,
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500185 utils::eDest dest) {
186 int index = (int)dest;
187 bool ret = false;
188 validate(index);
189 //Queue only if commit() has succeeded (and the bit set)
190 if(PipeBook::isUsed((int)dest)) {
191 ret = mPipeBook[index].mPipe->queueBuffer(fd, offset);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700192 }
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500193 return ret;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700194}
195
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500196void Overlay::setCrop(const utils::Dim& d,
197 utils::eDest dest) {
198 int index = (int)dest;
199 validate(index);
200 mPipeBook[index].mPipe->setCrop(d);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700201}
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700202
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500203void Overlay::setPosition(const utils::Dim& d,
204 utils::eDest dest) {
205 int index = (int)dest;
206 validate(index);
207 mPipeBook[index].mPipe->setPosition(d);
208}
209
210void Overlay::setTransform(const int orient,
211 utils::eDest dest) {
212 int index = (int)dest;
213 validate(index);
214
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700215 utils::eTransform transform =
216 static_cast<utils::eTransform>(orient);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500217 mPipeBook[index].mPipe->setTransform(transform);
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700218
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500219}
220
221void Overlay::setSource(const utils::PipeArgs args,
222 utils::eDest dest) {
223 int index = (int)dest;
224 validate(index);
225
226 PipeArgs newArgs(args);
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800227 if(PipeBook::getPipeType(dest) == OV_MDP_PIPE_VG) {
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500228 setMdpFlags(newArgs.mdpFlags, OV_MDP_PIPE_SHARE);
229 } else {
230 clearMdpFlags(newArgs.mdpFlags, OV_MDP_PIPE_SHARE);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700231 }
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800232
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800233 if(PipeBook::getPipeType(dest) == OV_MDP_PIPE_DMA) {
Jeykumar Sankaranb551ce42013-01-10 16:26:48 -0800234 setMdpFlags(newArgs.mdpFlags, OV_MDP_PIPE_FORCE_DMA);
235 } else {
236 clearMdpFlags(newArgs.mdpFlags, OV_MDP_PIPE_FORCE_DMA);
237 }
238
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500239 mPipeBook[index].mPipe->setSource(newArgs);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700240}
Naseer Ahmedf48aef62012-07-20 09:05:53 -0700241
Saurabh Shah5daeee52013-01-23 16:52:26 +0800242void Overlay::setVisualParams(const MetaData_t& metadata, utils::eDest dest) {
243 int index = (int)dest;
244 validate(index);
245 mPipeBook[index].mPipe->setVisualParams(metadata);
246}
247
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500248Overlay* Overlay::getInstance() {
249 if(sInstance == NULL) {
250 sInstance = new Overlay();
Naseer Ahmed29a26812012-06-14 00:56:20 -0700251 }
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500252 return sInstance;
Saurabh Shahc4d034f2012-09-27 15:55:15 -0700253}
254
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800255// Clears any VG pipes allocated to the fb devices
256// Generates a LUT for pipe types.
257int Overlay::initOverlay() {
258 int mdpVersion = qdutils::MDPVersion::getInstance().getMDPVersion();
259 int numPipesXType[OV_MDP_PIPE_ANY] = {0};
260 numPipesXType[OV_MDP_PIPE_RGB] =
261 qdutils::MDPVersion::getInstance().getRGBPipes();
262 numPipesXType[OV_MDP_PIPE_VG] =
263 qdutils::MDPVersion::getInstance().getVGPipes();
264 numPipesXType[OV_MDP_PIPE_DMA] =
265 qdutils::MDPVersion::getInstance().getDMAPipes();
266
267 int index = 0;
268 for(int X = 0; X < (int)OV_MDP_PIPE_ANY; X++) { //iterate over types
269 for(int j = 0; j < numPipesXType[X]; j++) { //iterate over num
270 PipeBook::pipeTypeLUT[index] = (utils::eMdpPipeType)X;
271 index++;
272 }
Saurabh Shahc4d034f2012-09-27 15:55:15 -0700273 }
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800274
Xiaoming Zhou5eff8b62013-05-01 20:56:09 -0400275 if (mdpVersion < qdutils::MDSS_V5 && mdpVersion != qdutils::MDP_V3_0_4) {
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800276 msmfb_mixer_info_req req;
277 mdp_mixer_info *minfo = NULL;
278 char name[64];
279 int fd = -1;
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700280 for(int i = 0; i < MAX_FB_DEVICES; i++) {
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800281 snprintf(name, 64, FB_DEVICE_TEMPLATE, i);
282 ALOGD("initoverlay:: opening the device:: %s", name);
283 fd = ::open(name, O_RDWR, 0);
284 if(fd < 0) {
285 ALOGE("cannot open framebuffer(%d)", i);
286 return -1;
287 }
288 //Get the mixer configuration */
289 req.mixer_num = i;
290 if (ioctl(fd, MSMFB_MIXER_INFO, &req) == -1) {
291 ALOGE("ERROR: MSMFB_MIXER_INFO ioctl failed");
292 close(fd);
293 return -1;
294 }
295 minfo = req.info;
296 for (int j = 0; j < req.cnt; j++) {
297 ALOGD("ndx=%d num=%d z_order=%d", minfo->pndx, minfo->pnum,
298 minfo->z_order);
299 // except the RGB base layer with z_order of -1, clear any
300 // other pipes connected to mixer.
301 if((minfo->z_order) != -1) {
302 int index = minfo->pndx;
303 ALOGD("Unset overlay with index: %d at mixer %d", index, i);
304 if(ioctl(fd, MSMFB_OVERLAY_UNSET, &index) == -1) {
305 ALOGE("ERROR: MSMFB_OVERLAY_UNSET failed");
306 close(fd);
307 return -1;
308 }
309 }
310 minfo++;
311 }
312 close(fd);
313 fd = -1;
314 }
315 }
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700316
317 FILE *displayDeviceFP = NULL;
318 const int MAX_FRAME_BUFFER_NAME_SIZE = 128;
319 char fbType[MAX_FRAME_BUFFER_NAME_SIZE];
320 char msmFbTypePath[MAX_FRAME_BUFFER_NAME_SIZE];
321 const char *strDtvPanel = "dtv panel";
322 const char *strWbPanel = "writeback panel";
323
324 for(int num = 1; num < MAX_FB_DEVICES; num++) {
325 snprintf (msmFbTypePath, sizeof(msmFbTypePath),
326 "/sys/class/graphics/fb%d/msm_fb_type", num);
327 displayDeviceFP = fopen(msmFbTypePath, "r");
328
329 if(displayDeviceFP){
330 fread(fbType, sizeof(char), MAX_FRAME_BUFFER_NAME_SIZE,
331 displayDeviceFP);
332
333 if(strncmp(fbType, strDtvPanel, strlen(strDtvPanel)) == 0) {
334 sDpyFbMap[DPY_EXTERNAL] = num;
335 } else if(strncmp(fbType, strWbPanel, strlen(strWbPanel)) == 0) {
336 sDpyFbMap[DPY_WRITEBACK] = num;
337 }
338
339 fclose(displayDeviceFP);
340 }
341 }
342
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800343 return 0;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700344}
345
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700346bool Overlay::displayCommit(const int& fd) {
Jeykumar Sankaran6a9bb9e2013-08-01 14:19:26 -0700347 utils::Dim roi;
348 return displayCommit(fd, roi);
349}
350
351bool Overlay::displayCommit(const int& fd, const utils::Dim& roi) {
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700352 //Commit
353 struct mdp_display_commit info;
354 memset(&info, 0, sizeof(struct mdp_display_commit));
355 info.flags = MDP_DISPLAY_COMMIT_OVERLAY;
Jeykumar Sankaran6a9bb9e2013-08-01 14:19:26 -0700356 info.roi.x = roi.x;
357 info.roi.y = roi.y;
358 info.roi.w = roi.w;
359 info.roi.h = roi.h;
360
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700361 if(!mdp_wrapper::displayCommit(fd, info)) {
Jeykumar Sankaran6a9bb9e2013-08-01 14:19:26 -0700362 ALOGE("%s: commit failed", __func__);
363 return false;
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700364 }
365 return true;
366}
367
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500368void Overlay::dump() const {
Saurabh Shah9dc88fc2013-07-15 16:02:30 -0700369#if PIPE_DEBUG
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500370 if(strlen(mDumpStr)) { //dump only on state change
Saurabh Shah9dc88fc2013-07-15 16:02:30 -0700371 ALOGD("%s\n", mDumpStr);
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500372 }
Saurabh Shah9dc88fc2013-07-15 16:02:30 -0700373#endif
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500374}
375
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800376void Overlay::getDump(char *buf, size_t len) {
377 int totalPipes = 0;
Saurabh Shahae61b2b2013-04-10 16:37:25 -0700378 const char *str = "\nOverlay State\n\n";
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800379 strncat(buf, str, strlen(str));
380 for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
381 if(mPipeBook[i].valid()) {
382 mPipeBook[i].mPipe->getDump(buf, len);
383 char str[64] = {'\0'};
Saurabh Shahae61b2b2013-04-10 16:37:25 -0700384 snprintf(str, 64, "Display=%d\n\n", mPipeBook[i].mDisplay);
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800385 strncat(buf, str, strlen(str));
386 totalPipes++;
387 }
388 }
389 char str_pipes[64] = {'\0'};
Saurabh Shahae61b2b2013-04-10 16:37:25 -0700390 snprintf(str_pipes, 64, "Pipes=%d\n\n", totalPipes);
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800391 strncat(buf, str_pipes, strlen(str_pipes));
392}
393
Sushil Chauhanbd3ea922013-05-15 12:25:26 -0700394void Overlay::clear(int dpy) {
395 for(int i = 0; i < PipeBook::NUM_PIPES; i++) {
396 if (mPipeBook[i].mDisplay == dpy) {
397 // Mark as available for this round
398 PipeBook::resetUse(i);
399 PipeBook::resetAllocation(i);
Saurabh Shahdf0be752013-05-23 14:40:00 -0700400 if(mPipeBook[i].valid()) {
401 mPipeBook[i].mPipe->forceSet();
402 }
Sushil Chauhanbd3ea922013-05-15 12:25:26 -0700403 }
404 }
405}
406
Saurabh Shahb8f58e22013-09-26 16:20:07 -0700407void Overlay::initScalar() {
408#ifdef USES_QSEED_SCALAR
409 if(sLibScaleHandle == NULL) {
410 sLibScaleHandle = dlopen("libscale.so", RTLD_NOW);
411 }
412
413 if(sLibScaleHandle) {
414 if(sScale == NULL) {
415 Scale* (*getInstance)();
416 *(void **) &getInstance = dlsym(sLibScaleHandle, "getInstance");
417 if(getInstance) {
418 sScale = getInstance();
419 }
420 }
421 }
422#endif
423}
424
425void Overlay::destroyScalar() {
426#ifdef USES_QSEED_SCALAR
427 if(sLibScaleHandle) {
428 if(sScale) {
429 void (*destroyInstance)(Scale*);
430 *(void **) &destroyInstance = dlsym(sLibScaleHandle,
431 "destroyInstance");
432 if(destroyInstance) {
433 destroyInstance(sScale);
434 sScale = NULL;
435 }
436 }
437 dlclose(sLibScaleHandle);
438 sLibScaleHandle = NULL;
439 }
440#endif
441}
442
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500443void Overlay::PipeBook::init() {
444 mPipe = NULL;
445 mDisplay = DPY_UNUSED;
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700446 mMixer = MIXER_UNUSED;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500447}
448
449void Overlay::PipeBook::destroy() {
450 if(mPipe) {
451 delete mPipe;
452 mPipe = NULL;
453 }
454 mDisplay = DPY_UNUSED;
Saurabh Shahaf5f5972013-07-30 13:56:35 -0700455 mMixer = MIXER_UNUSED;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500456}
457
458Overlay* Overlay::sInstance = 0;
Saurabh Shahc8118ac2013-06-27 10:03:19 -0700459int Overlay::sDpyFbMap[DPY_MAX] = {0, -1, -1};
Saurabh Shah85234ec2013-04-12 17:09:00 -0700460int Overlay::sDMAMode = DMA_LINE_MODE;
Saurabh Shah784e9852013-08-21 16:51:21 -0700461int Overlay::sForceSetBitmap = 0;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500462int Overlay::PipeBook::NUM_PIPES = 0;
463int Overlay::PipeBook::sPipeUsageBitmap = 0;
464int Overlay::PipeBook::sLastUsageBitmap = 0;
465int Overlay::PipeBook::sAllocatedBitmap = 0;
Sushil Chauhan07a2c762013-03-06 15:36:49 -0800466utils::eMdpPipeType Overlay::PipeBook::pipeTypeLUT[utils::OV_MAX] =
467 {utils::OV_MDP_PIPE_ANY};
Saurabh Shahb8f58e22013-09-26 16:20:07 -0700468void *Overlay::sLibScaleHandle = NULL;
469scale::Scale *Overlay::sScale = NULL;
Naseer Ahmed758bfc52012-11-28 17:02:08 -0500470
471}; // namespace overlay