Browse files

overlay: Swap flips on 90 only for older mdp version.

Older mdp rotator does 90 first and flip next,
forcing HAL to swap flips, in presence of 90.

Newer mdp does flip first and 90 next, owing to DMA pipe.
(Also similar to GPU flip handling). So we can pass flips as-is.

Change-Id: I379509a07e45966262005666e7727e7923079d3a
  • Loading branch information...
1 parent 07009fc commit 0e7dadd80212935b86f750677e48390ee86ac0e3 Saurabh Shah committed with Apr 10, 2013
@@ -135,8 +135,6 @@ bool MdpCtrl::setTransform(const utils::eTransform& orient,
const bool& rotUsed) {
int rot = utils::getMdpOrient(orient);
- //getMdpOrient will switch the flips if the source is 90 rotated.
- //Clients in Android dont factor in 90 rotation while deciding the flip.
mOrientation = static_cast<utils::eTransform>(rot);
//Rotator can be requested by client even if layer has 0 orientation.
@@ -109,8 +109,6 @@ void MdpRot::setTransform(const utils::eTransform& rot, const bool& rotUsed)
int r = utils::getMdpOrient(rot);
- //getMdpOrient will switch the flips if the source is 90 rotated.
- //Clients in Android dont factor in 90 rotation while deciding the flip.
mOrientation = static_cast<utils::eTransform>(r);
@@ -101,8 +101,6 @@ void MdssRot::setTransform(const utils::eTransform& rot, const bool& rotUsed)
int flags = utils::getMdpOrient(rot);
if (flags != -1)
- //getMdpOrient will switch the flips if the source is 90 rotated.
- //Clients in Android dont factor in 90 rotation while deciding the flip.
mOrientation = static_cast<utils::eTransform>(flags);
ALOGE_IF(DEBUG_OVERLAY, "%s: rot=%d", __FUNCTION__, flags);
@@ -263,6 +263,40 @@ int getMdpFormat(int format) {
return -1;
+int getMdpOrient(eTransform rotation) {
+ int retTrans = 0;
+ bool trans90 = false;
+ int mdpVersion = qdutils::MDPVersion::getInstance().getMDPVersion();
+ bool aFamily = (mdpVersion < qdutils::MDSS_V5);
+ ALOGD_IF(DEBUG_OVERLAY, "%s: In rotation = %d", __FUNCTION__, rotation);
+ if(rotation & OVERLAY_TRANSFORM_ROT_90) {
+ retTrans |= MDP_ROT_90;
+ trans90 = true;
+ }
+ if(rotation & OVERLAY_TRANSFORM_FLIP_H) {
+ if(trans90 && aFamily) {
+ //Swap for a-family, since its driver does 90 first
+ retTrans |= MDP_FLIP_UD;
+ } else {
+ retTrans |= MDP_FLIP_LR;
+ }
+ }
+ if(rotation & OVERLAY_TRANSFORM_FLIP_V) {
+ if(trans90 && aFamily) {
+ //Swap for a-family, since its driver does 90 first
+ retTrans |= MDP_FLIP_LR;
+ } else {
+ retTrans |= MDP_FLIP_UD;
+ }
+ }
+ ALOGD_IF(DEBUG_OVERLAY, "%s: Out rotation = %d", __FUNCTION__, retTrans);
+ return retTrans;
int getOverlayMagnificationLimit()
if(qdutils::MDPVersion::getInstance().getMDPVersion() > 400)
@@ -561,29 +561,6 @@ inline void Dim::dump() const {
ALOGE("== Dump Dim x=%d y=%d w=%d h=%d start/end ==", x, y, w, h);
-inline int getMdpOrient(eTransform rotation) {
- ALOGE_IF(DEBUG_OVERLAY, "%s: rot=%d", __FUNCTION__, rotation);
- switch(rotation)
- {
- case OVERLAY_TRANSFORM_0 : return 0;
- case OVERLAY_TRANSFORM_ROT_90: return MDP_ROT_90;
- //getMdpOrient will switch the flips if the source is 90 rotated.
- //Clients in Android dont factor in 90 rotation while deciding flip.
- return MDP_ROT_90 | MDP_FLIP_LR;
- return MDP_ROT_90 | MDP_FLIP_UD;
- case OVERLAY_TRANSFORM_ROT_180: return MDP_ROT_180;
- case OVERLAY_TRANSFORM_ROT_270: return MDP_ROT_270;
- default:
- ALOGE("%s: invalid rotation value (value = 0x%x",
- __FUNCTION__, rotation);
- }
- return -1;
inline int getRotOutFmt(uint32_t format) {
switch (format) {

15 comments on commit 0e7dadd

I'm using your repos in the last 3 months and display works very good. Only bug that I can't find where it comes from is this:

E/memalloc(  218): /dev/pmem: Failed to map buffer size:4009984 offset:3891200 fd:75 Error: Invalid argument
E/gralloc (  218): Could not mmap handle 0x1674228, fd=75 (Invalid argument)
E/gralloc (  218): gralloc_register_buffer: gralloc_map failed
E/libgenlock(  218): perform_lock_unlock_operation: GENLOCK_IOC_DREADLOCK failed (lockType0x1,err=Not a typewriter fd=75)
W/GraphicBufferMapper(  218): registerBuffer(0x1674228) failed -22 (Invalid argument)
E/GraphicBuffer(  218): unflatten: registerBuffer failed: Invalid argument (-22)

The above log is captured while opening camera. There is no preview on camera but capturing photos/videos works perfectly.
I can't find any info on the net or anyone with the same problem fixed. I'd be glad if someone can help, I'm struggling to find a solution to this in the past 2 months without success


arco replied Jun 26, 2013

Hmm, pmem and genlock drivers are up-to-date in kernel, and include files in device overlay matches kernel?

Try also setting these permissions in ueventd.qcom.rc

/dev/genlock 0666 system system
/dev/kgsl 0666 system system
/dev/kgsl-3d0 0666 system system
/dev/kgsl-2d0 0666 root root
/dev/kgsl-2d1 0666 root root
/dev/pmem_smipool* 0660 system camera

Yes, drivers & overlay includes are up to date (3.4 kernel)

I was missing some of the ueventd entries, I'm going to try again and report back.

I gave the right ueventd permissions but locat is still flooded by these errors:

W/GraphicBufferMapper(  230): lock(...) failed -22 (Invalid argument)
E/qdmemalloc(  230): /dev/pmem: Failed to map buffer size:3846144 offset:3727360 fd:68 Error: Invalid argument
E/qdgralloc(  230): Could not mmap handle 0x1468a80, fd=68 (Invalid argument)
E/qdgenlock(  230): perform_lock_unlock_operation: GENLOCK_IOC_DREADLOCK failed (lockType0x1,err=Invalid argument fd=68)
E/qdgralloc(  230): gralloc_lock: genlock_lock_buffer (lockType=0x2) failed

Some more info: this happens with the old 2.6.32 kernel too, 3.0.8 and 3.4.50 too

Camera libs are from ICS, I tried the -DICS_CAMERA_BLOB flag without success (also, front camera broke with this flag).

Preview works with this hack but preview image is stretched: LegacyXperia/android_packages_apps_Gallery2@08b8d56


arco replied Jun 27, 2013

Strange. But it's ok if you revert this patch?

Sorry if I was confusing by commenting on this commit, you mean revert this commit?
No, it doesn't work, it never worked with any display repository I tried on cm-10.1.

I'm not sure of the behaviour in cm10, I think it doesn't work there too since we had to use LegacyCamera. I'll try cm10 with the normal camera app and report back.


arco replied Jun 28, 2013

Ah ok. I thought you meant this patch was causing it, since you posted here.. :)

It sounds to me like it's your camera libs that's the fault here. That it's not quite compatible with pmem/genlock in kernel, or gralloc HAL.

Thanks for the hints, the errors are gone with 2 lines reverted from stock 2.6.32 kernel in kernel pmem driver.
Preview is still broken, now instead of solid grey color, it flashes between green & gray artifacts, kernel panic on shot/video. More work needed...

Hey, if you're interested in building cm-10.2, you can save some time using my updated repos here:

For now, build completes successfully but I haven't tested on actual device.


arco replied Jul 26, 2013

Ok, thanks. :)

Hello, ive been trying the last day to compile cm10.2 and im getting the error:
libandroid_runtime (/home/doadin/CM10.2/out/target/product/ancora_tmo/obj/SHARED_LIBRARIES/libandroid_runtime_intermediates/LINKED/
frameworks/av/media/libstagefright/AwesomePlayer.cpp:1012: error: undefined reference to 'android::LPAPlayer::mObjectsAlive'
frameworks/av/media/libstagefright/AwesomePlayer.cpp:1084: error: undefined reference to 'android::LPAPlayer::LPAPlayer(android::spandroid::MediaPlayerBase::AudioSink const&, bool&, android::AwesomePlayer_)'
frameworks/av/media/libstagefright/AwesomePlayer.cpp:1685: error: undefined reference to 'android::LPAPlayer::mObjectsAlive'
collect2: error: ld returned 1 exit status
make: *_* [/home/doadin/CM10.2/out/target/product/ancora_tmo/obj/SHARED_LIBRARIES/libstagefright_intermediates/LINKED/] Error 1
make: *** Waiting for unfinished jobs....


If anyone has any ideas(besides wait for the source to be cleaned/updated).(is there any better way?) Id appreciate it thank you.

Thanks. Do you have one booting yet?


arco replied Jul 31, 2013

No, haven't even worked on CM-10.2 for the Galaxy W yet. Too busy with the S4 Mini right now, so I don't know when I will have time to work on it.

Please sign in to comment.