Portrait display before Android 1.5

Source: Internet
Author: User

The screen is landscape. You need to display it as portrait by default.

1. Rotate the framebuffer in the kernel.
Add fbcon = rotate: 1 to the startup parameters (0: normal screen; 1: instant clock to 90 degrees; 2: instant clock to 180 degrees; 3: instant clock to 270 degrees ;)
The generated Autoconf. h contains similar items:
# Define config_cmdline "console = ttysac0, 115200 fbcon = rotate: 1"

This item is parsed in $ (kernel)/Drivers/Video/console/fbcon. c
Static int _ init fb_lele_setup (char * this_opt );
Only initialize the variable initial_rotation, and initial_rotation will be passed to other required structures.
Note: For more information, see $ (kernel)/documentation/FB/fbcon.txt.

2. Android OS Rotating Screen
The system uses portrait screens by default, while the mid uses landscape screens. Therefore, a conversion operation is required.
Portrait landscape <------ Display Mode
Rotation_0 rotation_90
Rotation_90 rotation_180
Rotation_180 rotation_270
Rotation_270 rotation_0

While Source
In code, the rotation_180 and rotation_270 are processed less, only in the sensor and keyqueue sections.
Screen, change surface. rotation_0 in Android to surface. rotation_90, and surface. rotation_90.
Change to surface. rotation_0. In this way, the screen after startup is portrait.
After the modification, it is displayed by landscape at startup, and will be automatically rotated to portrait mode soon. This is because
$ (Cupcake)/frameworks/base/services/Java/COM/Android/Server/windowmanagerservice. Java
Enablescreenafterboot ()-> enablescreen ()-> mpolicy. enablescreenafterboot (). mpolicy is the parent class pointer and can be directed
Phonewindowmanager or midwindowmanager, in the configuration file $ (cupcake)/build/target/product/CORE. mk
Product_policy: = Android. policy_phone
// Product_policy: = Android. policy_mid
.
Phonewindowmanager: enablescreenafterboot ()-> updaterotation (surface. flags_orientation_animation_disable)-> mwindowmanager. setrotation ()
Complete the settings rotation and clear the logo.

3. Portrait screen during startup
During the startup process, the screen width and height are displayed by default and will not be rotated. to display the logo, the screen is displayed in portrait mode, that is, the rotation is 90 degrees. You need to do the following:
$ (Cupcake)/frameworks/base/libs/surfaceflinger. cpp
Status_t surfaceflinger: readytorun ()
// 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 ();
Submit
Change the width and height, so that the viewport shape created by OpenGL is vertical. You can also modify the following function parameters, but there are too many parameters, so it is easy to exchange them.
But how can we make this vertical viewport Rotate 90 degrees? Graphicplane: mglobaltransform is used here.
. It indicates the final result to be rotated. Therefore, when creating graphicplane, initialize mglobaltransform to rotate 90 degrees.
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). Make sure to modify mglobaltransform:
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 (); the default rotation is 90 degrees. See status_t graphicplane: orientationtotransfrom
To:
Void transform: reset (){
Mtransform. Reset ();
Mtype = 0;
Set (0,-1, 1, 0); // Jeff
Set (800,0 );
}
Refer:
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; C = 1; 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;
}
After modification, the screen is displayed by default (90 degrees of rotation.

 

Http://blog.csdn.net/knock/archive/2010/03/01/5335767.aspx

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.