Skip to content

Commit

Permalink
overlay: Swap flips on 90 only for older mdp version.
Browse files Browse the repository at this point in the history
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
Saurabh Shah authored and arco committed May 4, 2013
1 parent 07009fc commit 0e7dadd
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 29 deletions.
2 changes: 0 additions & 2 deletions liboverlay/overlayMdp.cpp
Expand Up @@ -135,8 +135,6 @@ bool MdpCtrl::setTransform(const utils::eTransform& orient,
const bool& rotUsed) { const bool& rotUsed) {
int rot = utils::getMdpOrient(orient); int rot = utils::getMdpOrient(orient);
setUserData(rot); setUserData(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>(rot); mOrientation = static_cast<utils::eTransform>(rot);


//Rotator can be requested by client even if layer has 0 orientation. //Rotator can be requested by client even if layer has 0 orientation.
Expand Down
2 changes: 0 additions & 2 deletions liboverlay/overlayMdpRot.cpp
Expand Up @@ -109,8 +109,6 @@ void MdpRot::setTransform(const utils::eTransform& rot, const bool& rotUsed)
{ {
int r = utils::getMdpOrient(rot); int r = utils::getMdpOrient(rot);
setRotations(r); setRotations(r);
//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); mOrientation = static_cast<utils::eTransform>(r);
ALOGE_IF(DEBUG_OVERLAY, "%s: r=%d", __FUNCTION__, r); ALOGE_IF(DEBUG_OVERLAY, "%s: r=%d", __FUNCTION__, r);


Expand Down
2 changes: 0 additions & 2 deletions liboverlay/overlayMdssRot.cpp
Expand Up @@ -101,8 +101,6 @@ void MdssRot::setTransform(const utils::eTransform& rot, const bool& rotUsed)
int flags = utils::getMdpOrient(rot); int flags = utils::getMdpOrient(rot);
if (flags != -1) if (flags != -1)
setRotations(flags); setRotations(flags);
//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); mOrientation = static_cast<utils::eTransform>(flags);
ALOGE_IF(DEBUG_OVERLAY, "%s: rot=%d", __FUNCTION__, flags); ALOGE_IF(DEBUG_OVERLAY, "%s: rot=%d", __FUNCTION__, flags);


Expand Down
34 changes: 34 additions & 0 deletions liboverlay/overlayUtils.cpp
Expand Up @@ -263,6 +263,40 @@ int getMdpFormat(int format) {
return -1; 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() int getOverlayMagnificationLimit()
{ {
if(qdutils::MDPVersion::getInstance().getMDPVersion() > 400) if(qdutils::MDPVersion::getInstance().getMDPVersion() > 400)
Expand Down
23 changes: 0 additions & 23 deletions liboverlay/overlayUtils.h
Expand Up @@ -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); 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_FLIP_V: return MDP_FLIP_UD;
case OVERLAY_TRANSFORM_FLIP_H: return MDP_FLIP_LR;
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.
case OVERLAY_TRANSFORM_ROT_90_FLIP_V:
return MDP_ROT_90 | MDP_FLIP_LR;
case OVERLAY_TRANSFORM_ROT_90_FLIP_H:
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) { inline int getRotOutFmt(uint32_t format) {
switch (format) { switch (format) {
#ifndef QCOM_MISSING_PIXEL_FORMATS #ifndef QCOM_MISSING_PIXEL_FORMATS
Expand Down

15 comments on commit 0e7dadd

@mikeNG
Copy link

@mikeNG mikeNG commented on 0e7dadd Jun 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Owner

@arco arco commented on 0e7dadd Jun 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@mikeNG
Copy link

@mikeNG mikeNG commented on 0e7dadd Jun 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mikeNG
Copy link

@mikeNG mikeNG commented on 0e7dadd Jun 27, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@mikeNG
Copy link

@mikeNG mikeNG commented on 0e7dadd Jun 27, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Owner

@arco arco commented on 0e7dadd Jun 27, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@mikeNG
Copy link

@mikeNG mikeNG commented on 0e7dadd Jun 27, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Owner

@arco arco commented on 0e7dadd Jun 28, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mikeNG
Copy link

@mikeNG mikeNG commented on 0e7dadd Jul 1, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...

@mikeNG
Copy link

@mikeNG mikeNG commented on 0e7dadd Jul 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, if you're interested in building cm-10.2, you can save some time using my updated repos here:
https://github.com/LegacyXperia/android_hardware_qcom_display-legacy/tree/cm-10.2
https://github.com/LegacyXperia/android_hardware_qcom_media-legacy/tree/cm-10.2

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

@arco
Copy link
Owner

@arco arco commented on 0e7dadd Jul 26, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, thanks. :)

@doadin
Copy link

@doadin doadin commented on 0e7dadd Jul 30, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/libandroid_runtime.so)
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/libstagefright.so] Error 1
make: *** Waiting for unfinished jobs....
doadin@doadinbigbuildbox:~/CM10.2$

Sources:
https://github.com/doadin/Cyanogenmod-local_manifests/blob/master/cm10.2/local_manifest.xml

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

@arco
Copy link
Owner

@arco arco commented on 0e7dadd Jul 31, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@doadin
Copy link

@doadin doadin commented on 0e7dadd Jul 31, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Do you have one booting yet?

@arco
Copy link
Owner

@arco arco commented on 0e7dadd Jul 31, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.