LCD横竖屏显示


1)kernel 竖屏
选中:
make menuconfig ---> Device Drivers  ---> Graphics support  ---> Console display driver support  ---> Framebuffer Console Rotation


make menuconfig

                ---> Boot options  启动参数修改为:console=ttySAC2,115200 init=/linuxrc fbcon=rotate:1


      说明: fbcon=rotate:<n>

        This option changes the orientation angle of the console display. The
        value 'n' accepts the following:

          0 - normal orientation (0 degree)
          1 - clockwise orientation (90 degrees)
          2 - upside down orientation (180 degrees)
          3 - counterclockwise orientation (270 degrees)



2)Android OS 竖屏

文件:./native/services/surfaceflinger/SurfaceFlinger.cpp

status_t SurfaceFlinger::getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) {
    ...
 738
//    int displayOrientation = DisplayState::eOrientationDefault;
    int displayOrientation = isplayState::eOrientation90;          // 加上这行
 740     char property[PROPERTY_VALUE_MAX];
 741     if (type == DisplayDevice::DISPLAY_PRIMARY) {
 742         if (property_get("ro.sf.hwrotation", property, NULL) > 0) {
 743             switch (atoi(property)) {
 744                 case 90:
 745                     displayOrientation = DisplayState::eOrientation90;
 746                     break;
 747                 case 270:
 748                     displayOrientation = DisplayState::eOrientation270;
 749                     break;
 750             }
 751         }
 752     }
 753
 754     if (displayOrientation & DisplayState::eOrientationSwapMask) {
 755         swap(width, height);
 756     }
 757
 758     info->w = width;
 759     info->h = height;
 760     info->xdpi = xdpi;
 761     info->ydpi = ydpi;
 762     info->fps = float(1e9 / hwc.getRefreshPeriod(type));
 763
 764     // All non-virtual displays are currently considered secure.
 765     info->secure = true;
 766
 767     return NO_ERROR;
 768 }
a:     device 中init.rc修改 竖屏
zhz@zhz:~/imx6-android-4.4.3/android/device/fsl/sabresd_6dq$ vim init.rc
    #Define the config for dual camera
    setprop camera.disable_zsl_mode 1
    #For landscape mode, orient is 0
    #For portrait mode, orient is 90
    #the android before honycomb are all in portrait mode
    setprop back_camera_name ov5640_mipi
    setprop back_camera_orient 0
    setprop front_camera_name uvc,ov5642_camera,ov5640_camera
    setprop front_camera_orient 0

    # Set OpenGLES version
    setprop ro.opengles.version 196608

    # Set rotation to 270 to cofigure as portrait mode
    setprop ro.sf.hwrotation 0            #指定默认输出不旋转(我们默认输出时竖屏)
    #setprop ro.sf.hwrotation 270   指定旋转270度输出

    # Set the density to 160dpi, default 128dpi is not good
    setprop ro.sf.lcd_density 160


b: . 这个指定角度,Android默认只有0度和270度有效,180度无效,如果想使用180度,需要修改源码
修改文件frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp
if (type == DisplayDevice::DISPLAY_PRIMARY) {
    if (property_get("ro.sf.hwrotation", property, NULL) > 0) {
        switch (atoi(property)) {
            case 90:
                displayOrientation = DisplayState::eOrientation90;
                break;
            case 270:
                displayOrientation = DisplayState::eOrientation270;
                break;
         case 180:
                displayOrientation = DisplayState::eOrientation180;
                break;
        }
    }
}
这样子就支持了180度了在方法

3. 还有更详细的 - Android 4.1 默认窗体旋转180度  
1).设置属性值
在/out/target/product/sabresd_6dq/system/build.prop文件中加入
ro.sf.hwrotation=180
2).设置窗体默认显示方向
在frameworks/native/services/surfaceflinger/SurfaceFlinger.cpp文件中找到方法
getDisplayInfo
switch (atoi(property)) 加入
 case 180:
                displayOrientation = DisplayState::eOrientation180;
                break;


3).设置窗体动画旋转方向
     a > 在frameworks/base/core/java/android/view/Surface.java 加入方法
public static int getDefaultRotation(){  
                return android.os.SystemProperties.getInt("ro.sf.hwrotation", 0);//180  
            }  
 
 
            /**
            * @hide
            */    
            public static int getDefaultRotationIndex(){  
                int rotation = getDefaultRotation();  
        switch(rotation){  
        case 0:  
            return ROTATION_0;  
        case 90:  
            return ROTATION_90;  
        case 180:  
            return ROTATION_180;  
        case 270:  
            return ROTATION_270;  
        }  
        return ROTATION_0;  
    }  
b > 在frameworks/base/services/java/com/android/server/vm/ScreenRotationAnimation.java 文件中找到(android4.1) 方法setRotation
或(android4.2)方法setRotationInTransaction 修改 deltaRotation(rotation,Surface.ROTATION_0);
为deltaRotation(rotation,Surface. getDefaultRotationIndex());



  • 1
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值