blob: d87bee60110a5aa016b25313ce416d03bfdc0a31 [file] [log] [blame]
Naseer Ahmed29a26812012-06-14 00:56:20 -07001/*
Arun Kumar K.R7e5a1f82014-01-22 10:36:16 -08002* Copyright (c) 2011-2014, 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
30#include <stdlib.h>
Saurabh Shahdb7ae312013-03-19 15:45:24 -070031#include <math.h>
Naseer Ahmed29a26812012-06-14 00:56:20 -070032#include <utils/Log.h>
33#include <linux/msm_mdp.h>
34#include <cutils/properties.h>
35#include "gralloc_priv.h"
Naseer Ahmed29a26812012-06-14 00:56:20 -070036#include "overlayUtils.h"
37#include "mdpWrapper.h"
Saurabh Shah94822ee2012-08-17 16:48:43 -070038#include "mdp_version.h"
Manoj Kumar AVM8a220812013-10-10 11:46:06 -070039#include <hardware/hwcomposer_defs.h>
Naseer Ahmed29a26812012-06-14 00:56:20 -070040
41// just a helper static thingy
42namespace {
43struct IOFile {
44 IOFile(const char* s, const char* mode) : fp(0) {
45 fp = ::fopen(s, mode);
46 if(!fp) {
47 ALOGE("Failed open %s", s);
48 }
49 }
50 template <class T>
51 size_t read(T& r, size_t elem) {
52 if(fp) {
53 return ::fread(&r, sizeof(T), elem, fp);
54 }
55 return 0;
56 }
57 size_t write(const char* s, uint32_t val) {
58 if(fp) {
59 return ::fprintf(fp, s, val);
60 }
61 return 0;
62 }
63 bool valid() const { return fp != 0; }
64 ~IOFile() {
65 if(fp) ::fclose(fp);
66 fp=0;
67 }
68 FILE* fp;
69};
70}
71
72namespace overlay {
73
74//----------From class Res ------------------------------
Naseer Ahmedf48aef62012-07-20 09:05:53 -070075const char* const Res::fbPath = "/dev/graphics/fb%u";
Naseer Ahmed29a26812012-06-14 00:56:20 -070076const char* const Res::rotPath = "/dev/msm_rotator";
Naseer Ahmed29a26812012-06-14 00:56:20 -070077//--------------------------------------------------------
78
79
80
81namespace utils {
Ajay Dudanicb3da0a2012-09-07 13:37:49 -070082
Naseer Ahmed29a26812012-06-14 00:56:20 -070083//--------------------------------------------------------
Naseer Ahmedaf49e212012-07-31 19:13:41 -070084//Refer to graphics.h, gralloc_priv.h, msm_mdp.h
Naseer Ahmed29a26812012-06-14 00:56:20 -070085int getMdpFormat(int format) {
86 switch (format) {
Naseer Ahmedaf49e212012-07-31 19:13:41 -070087 //From graphics.h
Naseer Ahmed29a26812012-06-14 00:56:20 -070088 case HAL_PIXEL_FORMAT_RGBA_8888 :
89 return MDP_RGBA_8888;
Naseer Ahmed29a26812012-06-14 00:56:20 -070090 case HAL_PIXEL_FORMAT_RGBX_8888:
91 return MDP_RGBX_8888;
Naseer Ahmedaf49e212012-07-31 19:13:41 -070092 case HAL_PIXEL_FORMAT_RGB_888:
93 return MDP_RGB_888;
94 case HAL_PIXEL_FORMAT_RGB_565:
95 return MDP_RGB_565;
Ramkumar Radhakrishnanb8eb16d2014-10-09 13:54:07 -070096 case HAL_PIXEL_FORMAT_RGBA_5551:
97 return MDP_RGBA_5551;
98 case HAL_PIXEL_FORMAT_RGBA_4444:
99 return MDP_RGBA_4444;
Naseer Ahmedaf49e212012-07-31 19:13:41 -0700100 case HAL_PIXEL_FORMAT_BGRA_8888:
101 return MDP_BGRA_8888;
Sushil Chauhan1f6d68f2013-10-11 11:49:35 -0700102 case HAL_PIXEL_FORMAT_BGRX_8888:
103 return MDP_BGRX_8888;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700104 case HAL_PIXEL_FORMAT_YV12:
Saurabh Shahae1044e2012-08-21 16:03:32 -0700105 return MDP_Y_CR_CB_GH2V2;
Naseer Ahmedaf49e212012-07-31 19:13:41 -0700106 case HAL_PIXEL_FORMAT_YCbCr_422_SP:
107 return MDP_Y_CBCR_H2V1;
108 case HAL_PIXEL_FORMAT_YCrCb_420_SP:
109 return MDP_Y_CRCB_H2V2;
110
111 //From gralloc_priv.h
112 case HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED:
113 return MDP_Y_CBCR_H2V2_TILE;
114 case HAL_PIXEL_FORMAT_YCbCr_420_SP:
115 return MDP_Y_CBCR_H2V2;
116 case HAL_PIXEL_FORMAT_YCrCb_422_SP:
117 return MDP_Y_CRCB_H2V1;
Ramkumar Radhakrishnanb52399c2013-08-06 20:17:29 -0700118 case HAL_PIXEL_FORMAT_YCbCr_422_I:
119 return MDP_YCBYCR_H2V1;
120 case HAL_PIXEL_FORMAT_YCrCb_422_I:
121 return MDP_YCRYCB_H2V1;
Naseer Ahmedaf49e212012-07-31 19:13:41 -0700122 case HAL_PIXEL_FORMAT_YCbCr_444_SP:
123 return MDP_Y_CBCR_H1V1;
124 case HAL_PIXEL_FORMAT_YCrCb_444_SP:
125 return MDP_Y_CRCB_H1V1;
Sushil Chauhanc5e61482012-08-22 17:13:32 -0700126 case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS:
Naseer Ahmed8f8cb8a2013-08-22 15:34:30 -0400127 case HAL_PIXEL_FORMAT_NV12_ENCODEABLE:
128 //NV12 encodeable format maps to the venus format on
129 //B-Family targets
Sushil Chauhanc5e61482012-08-22 17:13:32 -0700130 return MDP_Y_CBCR_H2V2_VENUS;
Raj Kamal8bb3b8f2015-03-24 16:22:17 +0530131 case HAL_PIXEL_FORMAT_YCrCb_420_SP_VENUS:
132 return MDP_Y_CRCB_H2V2_VENUS;
Naseer Ahmed29a26812012-06-14 00:56:20 -0700133 default:
Naseer Ahmedaf49e212012-07-31 19:13:41 -0700134 //Unsupported by MDP
Naseer Ahmedaf49e212012-07-31 19:13:41 -0700135 //---gralloc_priv.h-----
136 //HAL_PIXEL_FORMAT_YCrCb_420_SP_ADRENO = 0x7FA30C01
137 //HAL_PIXEL_FORMAT_R_8 = 0x10D
138 //HAL_PIXEL_FORMAT_RG_88 = 0x10E
Saurabh Shahfc3652f2013-02-15 13:15:45 -0800139 ALOGE("%s: Unsupported HAL format = 0x%x", __func__, format);
140 return -1;
141 }
142 // not reached
143 return -1;
144}
145
Sushil Chauhan65e26302015-01-14 10:48:57 -0800146int getMdpFormat(int format, int flags)
Manoj Kumar AVM8a220812013-10-10 11:46:06 -0700147{
Sushil Chauhan65e26302015-01-14 10:48:57 -0800148 bool uBwcEnabled = (flags & private_handle_t::PRIV_FLAGS_UBWC_ALIGNED);
149 bool tileEnabled = (flags & private_handle_t::PRIV_FLAGS_TILE_RENDERED);
150
151 // Use UBWC extension, if UBWC is enabled
152 if (uBwcEnabled) {
153 switch (format) {
154 case HAL_PIXEL_FORMAT_RGBA_8888:
155 return MDP_RGBA_8888_UBWC;
156 case HAL_PIXEL_FORMAT_RGB_565:
157 return MDP_RGB_565_UBWC;
158 case HAL_PIXEL_FORMAT_NV12_ENCODEABLE:
159 case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS:
160 case HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS_UBWC:
161 return MDP_Y_CBCR_H2V2_UBWC;
162 default:
163 ALOGE("%s: Unsupported HAL format = 0x%x", __func__, format);
164 break;
165 }
166 }
167
Manoj Kumar AVM8a220812013-10-10 11:46:06 -0700168 if(!tileEnabled) {
169 return getMdpFormat(format);
170 }
171 switch (format) {
172 case HAL_PIXEL_FORMAT_RGBA_8888 :
173 return MDP_RGBA_8888_TILE;
174 case HAL_PIXEL_FORMAT_RGBX_8888:
175 return MDP_RGBX_8888_TILE;
176 case HAL_PIXEL_FORMAT_RGB_565:
Manoj Kumar AVM5a5529b2014-02-24 18:16:37 -0800177 return MDP_RGB_565_TILE;
Manoj Kumar AVM8a220812013-10-10 11:46:06 -0700178 case HAL_PIXEL_FORMAT_BGRA_8888:
179 return MDP_BGRA_8888_TILE;
180 case HAL_PIXEL_FORMAT_BGRX_8888:
181 return MDP_BGRX_8888_TILE;
182 default:
183 return getMdpFormat(format);
184 }
185}
186
187
188
Saurabh Shahfc3652f2013-02-15 13:15:45 -0800189//Takes mdp format as input and translates to equivalent HAL format
190//Refer to graphics.h, gralloc_priv.h, msm_mdp.h for formats.
191int getHALFormat(int mdpFormat) {
192 switch (mdpFormat) {
193 //From graphics.h
194 case MDP_RGBA_8888:
195 return HAL_PIXEL_FORMAT_RGBA_8888;
196 case MDP_RGBX_8888:
197 return HAL_PIXEL_FORMAT_RGBX_8888;
198 case MDP_RGB_888:
199 return HAL_PIXEL_FORMAT_RGB_888;
200 case MDP_RGB_565:
201 return HAL_PIXEL_FORMAT_RGB_565;
Ramkumar Radhakrishnanb8eb16d2014-10-09 13:54:07 -0700202 case MDP_RGBA_5551:
203 return HAL_PIXEL_FORMAT_RGBA_5551;
204 case MDP_RGBA_4444:
205 return HAL_PIXEL_FORMAT_RGBA_4444;
Saurabh Shahfc3652f2013-02-15 13:15:45 -0800206 case MDP_BGRA_8888:
207 return HAL_PIXEL_FORMAT_BGRA_8888;
208 case MDP_Y_CR_CB_GH2V2:
209 return HAL_PIXEL_FORMAT_YV12;
210 case MDP_Y_CBCR_H2V1:
211 return HAL_PIXEL_FORMAT_YCbCr_422_SP;
212 case MDP_Y_CRCB_H2V2:
213 return HAL_PIXEL_FORMAT_YCrCb_420_SP;
214
215 //From gralloc_priv.h
216 case MDP_Y_CBCR_H2V2_TILE:
217 return HAL_PIXEL_FORMAT_YCbCr_420_SP_TILED;
218 case MDP_Y_CBCR_H2V2:
219 return HAL_PIXEL_FORMAT_YCbCr_420_SP;
220 case MDP_Y_CRCB_H2V1:
221 return HAL_PIXEL_FORMAT_YCrCb_422_SP;
Ramkumar Radhakrishnanb52399c2013-08-06 20:17:29 -0700222 case MDP_YCBYCR_H2V1:
223 return HAL_PIXEL_FORMAT_YCbCr_422_I;
224 case MDP_YCRYCB_H2V1:
225 return HAL_PIXEL_FORMAT_YCrCb_422_I;
226 case MDP_Y_CBCR_H1V1:
Saurabh Shahfc3652f2013-02-15 13:15:45 -0800227 return HAL_PIXEL_FORMAT_YCbCr_444_SP;
228 case MDP_Y_CRCB_H1V1:
229 return HAL_PIXEL_FORMAT_YCrCb_444_SP;
230 case MDP_Y_CBCR_H2V2_VENUS:
231 return HAL_PIXEL_FORMAT_YCbCr_420_SP_VENUS;
Raj Kamal8bb3b8f2015-03-24 16:22:17 +0530232 case MDP_Y_CRCB_H2V2_VENUS:
233 return HAL_PIXEL_FORMAT_YCrCb_420_SP_VENUS;
Saurabh Shahfc3652f2013-02-15 13:15:45 -0800234 default:
235 ALOGE("%s: Unsupported MDP format = 0x%x", __func__, mdpFormat);
Naseer Ahmed29a26812012-06-14 00:56:20 -0700236 return -1;
237 }
238 // not reached
239 return -1;
240}
241
Saurabh Shahd1a22782013-04-10 09:09:45 -0700242int getMdpOrient(eTransform rotation) {
243 int retTrans = 0;
244 bool trans90 = false;
245 int mdpVersion = qdutils::MDPVersion::getInstance().getMDPVersion();
246 bool aFamily = (mdpVersion < qdutils::MDSS_V5);
247
248 ALOGD_IF(DEBUG_OVERLAY, "%s: In rotation = %d", __FUNCTION__, rotation);
249 if(rotation & OVERLAY_TRANSFORM_ROT_90) {
250 retTrans |= MDP_ROT_90;
251 trans90 = true;
252 }
253
254 if(rotation & OVERLAY_TRANSFORM_FLIP_H) {
255 if(trans90 && aFamily) {
256 //Swap for a-family, since its driver does 90 first
257 retTrans |= MDP_FLIP_UD;
258 } else {
259 retTrans |= MDP_FLIP_LR;
260 }
261 }
262
263 if(rotation & OVERLAY_TRANSFORM_FLIP_V) {
264 if(trans90 && aFamily) {
265 //Swap for a-family, since its driver does 90 first
266 retTrans |= MDP_FLIP_LR;
267 } else {
268 retTrans |= MDP_FLIP_UD;
269 }
270 }
271
272 ALOGD_IF(DEBUG_OVERLAY, "%s: Out rotation = %d", __FUNCTION__, retTrans);
273 return retTrans;
274}
275
Saurabh Shah1a03d482013-05-29 13:44:20 -0700276void getDecimationFactor(const int& src_w, const int& src_h,
Saurabh Shahb6810df2014-06-17 16:00:22 -0700277 const int& dst_w, const int& dst_h, uint8_t& horzDeci,
278 uint8_t& vertDeci) {
279 horzDeci = 0;
280 vertDeci = 0;
281 float horDscale = ceilf((float)src_w / (float)dst_w);
282 float verDscale = ceilf((float)src_h / (float)dst_h);
Raj Kamal389d6e32014-08-04 14:43:24 +0530283 qdutils::MDPVersion& mdpHw = qdutils::MDPVersion::getInstance();
Saurabh Shah1a03d482013-05-29 13:44:20 -0700284
285 //Next power of 2, if not already
286 horDscale = powf(2.0f, ceilf(log2f(horDscale)));
287 verDscale = powf(2.0f, ceilf(log2f(verDscale)));
288
Raj Kamal389d6e32014-08-04 14:43:24 +0530289 //Since MDP can do downscale and has better quality, split the task
Saurabh Shah1a03d482013-05-29 13:44:20 -0700290 //between decimator and MDP downscale
Raj Kamal389d6e32014-08-04 14:43:24 +0530291 horDscale /= (float)mdpHw.getMaxMDPDownscale();
292 verDscale /= (float)mdpHw.getMaxMDPDownscale();
Saurabh Shahb6810df2014-06-17 16:00:22 -0700293
294 if((int)horDscale)
295 horzDeci = (uint8_t)log2f(horDscale);
296
297 if((int)verDscale)
298 vertDeci = (uint8_t)log2f(verDscale);
299
Jeykumar Sankaran39305802014-12-12 17:55:57 -0800300 if(src_w > (int) mdpHw.getMaxPipeWidth()) {
Saurabh Shahb6810df2014-06-17 16:00:22 -0700301 //If the client sends us something > what a layer mixer supports
302 //then it means it doesn't want to use split-pipe but wants us to
Saurabh Shahdbbf2aa2014-12-29 10:54:02 -0800303 //decimate. A minimum decimation of 1 will ensure that the width is
Saurabh Shahb6810df2014-06-17 16:00:22 -0700304 //always within layer mixer limits.
Saurabh Shahdbbf2aa2014-12-29 10:54:02 -0800305 const uint8_t minDeci = 1;
306 if(horzDeci < minDeci)
307 horzDeci = minDeci;
Saurabh Shahb6810df2014-06-17 16:00:22 -0700308 }
Saurabh Shah1a03d482013-05-29 13:44:20 -0700309}
310
Saurabh Shahacf10202013-02-26 10:15:15 -0800311static inline int compute(const uint32_t& x, const uint32_t& y,
312 const uint32_t& z) {
313 return x - ( y + z );
314}
315
Saurabh Shah76fd6552013-03-14 14:45:38 -0700316void preRotateSource(const eTransform& tr, Whf& whf, Dim& srcCrop) {
Saurabh Shahacf10202013-02-26 10:15:15 -0800317 if(tr & OVERLAY_TRANSFORM_FLIP_H) {
318 srcCrop.x = compute(whf.w, srcCrop.x, srcCrop.w);
319 }
320 if(tr & OVERLAY_TRANSFORM_FLIP_V) {
321 srcCrop.y = compute(whf.h, srcCrop.y, srcCrop.h);
322 }
323 if(tr & OVERLAY_TRANSFORM_ROT_90) {
324 int tmp = srcCrop.x;
325 srcCrop.x = compute(whf.h,
326 srcCrop.y,
327 srcCrop.h);
328 srcCrop.y = tmp;
329 swap(whf.w, whf.h);
330 swap(srcCrop.w, srcCrop.h);
331 }
Saurabh Shahacf10202013-02-26 10:15:15 -0800332}
333
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800334void getDump(char *buf, size_t len, const char *prefix,
335 const mdp_overlay& ov) {
336 char str[256] = {'\0'};
337 snprintf(str, 256,
Saurabh Shah2c8ad052014-08-15 13:27:46 -0700338 "%s id=%d z=%d alpha=%d mask=%d flags=0x%x H.Deci=%d,"
Saurabh Shahbd2d0832013-04-04 14:33:08 -0700339 "V.Deci=%d\n",
Saurabh Shah2c8ad052014-08-15 13:27:46 -0700340 prefix, ov.id, ov.z_order, ov.alpha,
Saurabh Shahbd2d0832013-04-04 14:33:08 -0700341 ov.transp_mask, ov.flags, ov.horz_deci, ov.vert_deci);
Ramkumar Radhakrishnan36bd5272014-01-31 20:03:01 -0800342 strlcat(buf, str, len);
Saurabh Shahae61b2b2013-04-10 16:37:25 -0700343 getDump(buf, len, "\tsrc", ov.src);
344 getDump(buf, len, "\tsrc_rect", ov.src_rect);
345 getDump(buf, len, "\tdst_rect", ov.dst_rect);
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800346}
347
Ramkumar Radhakrishnan36bd5272014-01-31 20:03:01 -0800348void getDump(char *buf, size_t len, const char *prefix,
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800349 const msmfb_img& ov) {
350 char str_src[256] = {'\0'};
351 snprintf(str_src, 256,
352 "%s w=%d h=%d format=%d %s\n",
353 prefix, ov.width, ov.height, ov.format,
354 overlay::utils::getFormatString(ov.format));
Ramkumar Radhakrishnan36bd5272014-01-31 20:03:01 -0800355 strlcat(buf, str_src, len);
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800356}
357
Ramkumar Radhakrishnan36bd5272014-01-31 20:03:01 -0800358void getDump(char *buf, size_t len, const char *prefix,
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800359 const mdp_rect& ov) {
360 char str_rect[256] = {'\0'};
361 snprintf(str_rect, 256,
362 "%s x=%d y=%d w=%d h=%d\n",
363 prefix, ov.x, ov.y, ov.w, ov.h);
Ramkumar Radhakrishnan36bd5272014-01-31 20:03:01 -0800364 strlcat(buf, str_rect, len);
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800365}
366
367void getDump(char *buf, size_t len, const char *prefix,
368 const msmfb_overlay_data& ov) {
369 char str[256] = {'\0'};
370 snprintf(str, 256,
371 "%s id=%d\n",
372 prefix, ov.id);
Ramkumar Radhakrishnan36bd5272014-01-31 20:03:01 -0800373 strlcat(buf, str, len);
Saurabh Shahae61b2b2013-04-10 16:37:25 -0700374 getDump(buf, len, "\tdata", ov.data);
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800375}
376
Ramkumar Radhakrishnan36bd5272014-01-31 20:03:01 -0800377void getDump(char *buf, size_t len, const char *prefix,
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800378 const msmfb_data& ov) {
379 char str_data[256] = {'\0'};
380 snprintf(str_data, 256,
Saurabh Shah7ef9ec92013-10-29 10:32:23 -0700381 "%s offset=%d memid=%d id=%d flags=0x%x\n",
382 prefix, ov.offset, ov.memory_id, ov.id, ov.flags);
Ramkumar Radhakrishnan36bd5272014-01-31 20:03:01 -0800383 strlcat(buf, str_data, len);
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800384}
385
386void getDump(char *buf, size_t len, const char *prefix,
387 const msm_rotator_img_info& rot) {
388 char str[256] = {'\0'};
389 snprintf(str, 256, "%s sessid=%u rot=%d, enable=%d downscale=%d\n",
390 prefix, rot.session_id, rot.rotations, rot.enable,
391 rot.downscale_ratio);
Ramkumar Radhakrishnan36bd5272014-01-31 20:03:01 -0800392 strlcat(buf, str, len);
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800393 getDump(buf, len, "\tsrc", rot.src);
394 getDump(buf, len, "\tdst", rot.dst);
395 getDump(buf, len, "\tsrc_rect", rot.src_rect);
396}
397
398void getDump(char *buf, size_t len, const char *prefix,
399 const msm_rotator_data_info& rot) {
400 char str[256] = {'\0'};
401 snprintf(str, 256,
Saurabh Shahae61b2b2013-04-10 16:37:25 -0700402 "%s sessid=%u\n",
403 prefix, rot.session_id);
Ramkumar Radhakrishnan36bd5272014-01-31 20:03:01 -0800404 strlcat(buf, str, len);
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800405 getDump(buf, len, "\tsrc", rot.src);
406 getDump(buf, len, "\tdst", rot.dst);
Saurabh Shah0d0a7cb2013-02-12 17:58:19 -0800407}
408
Sushil Chauhan1cac8152013-05-08 15:53:51 -0700409//Helper to even out x,w and y,h pairs
410//x,y are always evened to ceil and w,h are evened to floor
411void normalizeCrop(uint32_t& xy, uint32_t& wh) {
412 if(xy & 1) {
413 even_ceil(xy);
414 if(wh & 1)
415 even_floor(wh);
416 else
417 wh -= 2;
418 } else {
419 even_floor(wh);
420 }
421}
422
Naseer Ahmed29a26812012-06-14 00:56:20 -0700423} // utils
424
425} // overlay