Transferred from: http://blog.csdn.net/oyzhizhong/article/details/8131799
The screen is landscape, so it appears as portrait by default.
Rotate the framebuffer in 1.kernel.
Start parameters Add fbcon=rotate:1 (0: Normal screen; 1: clockwise to 90 degrees; 2: turn 180 degrees; 3: Shun clock to 270 degrees;)
There are similar entries in the last generated autoconf.h:
#define Config_cmdline "console=ttysac0,115200 fbcon=rotate:1"
Parsing of this item in $ (kernel)/drivers/video/console/fbcon.c
static int __init Fb_console_setup (char *this_opt);
Just go to initialize the variable initial_rotation, and then the initial_rotation will be passed to the other required structure.
Note: Refer to $ (kernel)/documentation/fb/fbcon.txt
2.android OS rotation screen
The system is for the vertical screen by default, and mid uses a horizontal screen, so a conversion action is required.
PORTRAIT LANDSCAPE <------screen display mode
Rotation_0 rotation_90
Rotation_90 rotation_180
rotation_180 rotation_270
rotation_270 rotation_0
The source code in the rotation_180 and rotation_270 processing less, only in the sensor and keyqueue part, so if only to let the system display as a vertical screen, the Android Surface.rotation_ 0 changed to Surface.rotation_90, while surface.rotation_90 to Surface.rotation_0. In this way, the screen after the start is the vertical screen.
After the change, the boot is still landscape display, into the home is also, will soon automatically rotate to portrait mode, which is due to
$ (cupcake)/frameworks/base/services/java/com/android/server/windowmanagerservice.java
In Enablescreenafterboot ()->performenablescreen ()->mpolicy.enablescreenafterboot (), MPolicy is a pointer to the parent class, which can point to
Phonewindowmanager or Midwindowmanager, by configuration file $ (cupcake) in/build/target/product/core.mk
Product_policy: = Android.policy_phone
Product_policy: = Android.policy_mid
To specify.
Phonewindowmanager::enablescreenafterboot ()->updaterotation (surface.flags_orientation_animation_disable)- >mwindowmanager.setrotation () Finish setting the rotation and clear the logo.
3. Vertical screen during startup
During the startup process, the default is to display the width and height of the screen, will not rotate, to make it display logo is vertical screen, that is, rotate 90 degrees, need to do the following work:
$ (cupcake)/frameworks/base/libs/surfaceflinger/surfaceflinger.cpp
status_t Surfaceflinger::readytorun () in
Const uint32_t w = hw.getwidth ();
Const uint32_t h = hw.getheight ();
Swap w&h for portrait display in Landscape panel. Jeff.
Const uint32_t h = hw.getwidth ();
Const uint32_t w = hw.getheight ();
Swap the width and height so that the viewport shape created with OpenGL is vertical. Modifying the following function parameters is also possible, but there are too many to swap. But how do you get this vertical viewport to spin 90 degrees? It's going to take graphicplane::mglobaltransform this transform. It indicates the result of the current final rotation. So the mglobaltransform is rotated 90 degrees when the Graphicplane is created.
Graphicplane::graphicplane ()
: MHw (0)
{
Add by Jeff. For default rotate Angel 90
Morientationtransform.reset ();
Morientation = Isurfacecomposer::eorientation90;
Mglobaltransform = Morientationtransform * mtransform;
}
This section is copied from status_t graphicplane::setorientation (int orientation), and notice that the Mglobaltransform is modified:
if (orientation = = Isurfacecomposer::eorientation90) {//isurfacecomposer::eorientationdefault//jeff
Make sure the default orientation is optimal
Morientationtransform.reset ();
Morientation = orientation;
Mglobaltransform = Mtransform;
Mglobaltransform = Morientationtransform * mtransform; Jeff
return no_error;
}
Note Morientationtransform.reset (), to be modified to the default rotation of 90 degrees. Refer to status_t Graphicplane::orientationtotransfrom
The settings in, modified to:
void Transform::reset () {
Mtransform.reset ();
mtype = 0;
Set (0,-1,1,0); Jeff
Set (800,0);
}
Reference:
status_t Graphicplane::orientationtotransfrom (
int orientation, int w, int h, transform* tr)
{
Float A, B, C, D, X, y;
Switch (orientation) {
Case Isurfacecomposer::eorientationdefault:
A=1; b=0; c=0; d=1; x=0; y=0;
Break
Case ISURFACECOMPOSER::EORIENTATION90:
a=0; B=-1; A=s; D=0; X=w; y=0;
Break
Case ISURFACECOMPOSER::EORIENTATION180:
A=-1; b=0; c=0; D=-1; X=w; Y=h;
Break
Case ISURFACECOMPOSER::EORIENTATION270:
a=0; B=1; C=-1; D=0; x=0; Y=h;
Break
Default
return bad_value;
}
Tr->set (A, B, C, D);
Tr->set (x, y);
return no_error;
}
Once modified, the vertical screen (rotated 90 degrees) is displayed by default.
Android Screen rotation