How to force display rotation by 180 degrees.

1,214 views
Skip to first unread message

Subodh Nijsure

unread,
Dec 1, 2013, 5:08:57 PM12/1/13
to android-...@googlegroups.com
Hi,

I am working with a custom hw board where due to some
hardware/mechanical design the display is upside down (in portrait
mode).

I want to basically rotate the display by 180 degress right from the
time system boots.

I have tried setting the ro.sf.hwrotation=180 and that doesn't work.
However surprisingly the ro.sf.hwrotation=90 & 270 degrees work.

I also tried rebuilding my ROM where I set eOrientationDefault = 2 in file
frameworks/native/include/gui/ISurfaceComposer.h and that didn't work either.

Any ideas as to why the 90/270 degree rotation works but not the 180?

FWIW I am working with Android 4.1.2 software.

Any pointers would be greatly appreciated, I have demo of this system
and want to come up with software solution for this mess, if possible.

Thanks.
-Subodh

Subodh Nijsure

unread,
Dec 3, 2013, 2:54:42 AM12/3/13
to android-...@googlegroups.com
FWIW. I am able to rotate the screen 180 degrees. Using following
"change" but the screen gets transformed along the vertical axis at
regular interval, anyone has pointers as to why that would be?

( I know this an unusual situation, I am trying to salvage hardware
that was put together bit in haste using software solution... )

+++ b/services/java/com/android/server/wm/ScreenRotationAnimation.java
@@ -279,15 +279,16 @@ class ScreenRotationAnimation {
Matrix outMatrix) {
switch (rotation) {
case Surface.ROTATION_0:
- outMatrix.reset();
+ outMatrix.reset();
+ outMatrix.setRotate(180, 0, 0);
+ outMatrix.postTranslate(width, height);
break;
case Surface.ROTATION_90:
outMatrix.setRotate(90, 0, 0);
outMatrix.postTranslate(height, 0);
break;
case Surface.ROTATION_180:
- outMatrix.setRotate(180, 0, 0);
- outMatrix.postTranslate(width, height);
+ outMatrix.reset();
break;
case Surface.ROTATION_270:
outMatrix.setRotate(270, 0, 0);

diff --git a/services/surfaceflinger/SurfaceFlinger.cpp
b/services/surfaceflinger/SurfaceFlinger.cpp
index 292b3ae..5914261 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2797,11 +2797,15 @@ void
GraphicPlane::setDisplayHardware(DisplayHardware *hw)
case 90:
displayOrientation = ISurfaceComposer::eOrientation90;
break;
+ case 180:
+ displayOrientation = ISurfaceComposer::eOrientation180;
+ break;
case 270:
displayOrientation = ISurfaceComposer::eOrientation270;
break;
}
}
+ displayOrientation = ISurfaceComposer::eOrientation180;

const float w = hw->getWidth();
const float h = hw->getHeight();


-Subodh
Reply all
Reply to author
Forward
0 new messages