Banana Pi M64 Android修改分辨率为480x1280横屏显示

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/babyshan1/article/details/79798781

由于项目需要,使用了一块480x1280分辨率的屏,但是M64官方Android系统只提供720p和1280p分辨率的选择,无法正常驱动这块屏。经过长期摸索,终于搞清楚了要修改的文件:

一、修改内核文件
1.lichee/linux-3.10/drivers/video/sunxi/disp2/hdmi/hdmi_core.c
修改自己屏幕的时序。
2.修改Android的hardware文件:
android/hardware/aw/hwc/tulip/hwc_uevent.cpp
android/hardware/aw/hwc/octopus/hwc_uevent.cpp
android/hardware/aw/hwc/astar/hal.cpp
android/hardware/aw/hwc/kylin/hal.cpp
修改 DISP_TV_MOD_720P_60HZDISP_TV_MOD_720P_50HZ分辨率为480x1280(原为1280x720) 

二、修改布局
由于需要横屏显示,所以还需要修改布局,以支持横屏
(一)支持横屏显示选项ro.sf.hwrotation
1.android/frameworks/native/services/surfaceflinger/DisplayDevice.h,
添加变量
    // Current active config
    int mActiveConfig; 
   //修改:支持横屏
   // Panel hardware rotation
   int32_t mHardwareRotation;
去掉    status_t orientationToTransfrom(int orientation,            int w, int h, Transform* tr);的 Static 声明
2.android/frameworks/native/services/surfaceflinger/DisplayDevice.cpp
DisplayDevice::DisplayDevice函数添加:
    property_get("ro.panel.mountflip", property, "0”);
    mPanelMountFlip = atoi(property);
    // initialize the display orientation transform.

DisplayDevice::orientationToTransfrom函数添加:
    //修改:支持橫屏
    if (mHardwareRotation && mType == DISPLAY_PRIMARY) { 
       orientation += mHardwareRotation;
        orientation %= 4;
    }

    switch (orientation) {

DisplayDevice::setProjection函数添加:
    if (!frame.isValid()) {
        // the destination frame can be invalid if it has never been set, 
       // in that case we assume the whole display frame. 
       //修改:支持橫屏
        if (mHardwareRotation == 1 || mHardwareRotation == 3) {
            frame = Rect(h, w);
        } else {
            frame = Rect(w, h); 
       }
        //frame = Rect(w, h); 
   }

3.android/frameworks/native/services/surfaceflinger/Surfaceflinger.cpp
SurfaceFlinger::getDisplayConfigs函数添加:
       //修改:支持橫屏
       char value[PROPERTY_VALUE_MAX]; 
       property_get("ro.sf.hwrotation", value, "0"); 
       int additionalRot = atoi(value) / 90; 
       if ((type == DisplayDevice::DISPLAY_PRIMARY) && (additionalRot & DisplayState::eOrientationSwapMask)) {
            info.h = hwConfig.width;
            info.w = hwConfig.height;
            info.xdpi = ydpi;
            info.ydpi = xdpi;
        }
        else {
            info.w = hwConfig.width;
            info.h = hwConfig.height;
            info.xdpi = xdpi;
            info.ydpi = ydpi;
        }
        /*
        info.w = hwConfig.width;
        info.h = hwConfig.height;
        info.xdpi = xdpi;
        info.ydpi = ydpi;
        */
        
        info.fps = float(1e9 / hwConfig.refresh);
        info.appVsyncOffset = VSYNC_EVENT_PHASE_OFFSET_NS;
        info.colorTransform = hwConfig.colorTransform; 


经过以上修改后,重新编译内核和源码,终于可以正常横屏显示了,希望能帮到有同样问题的朋友。

猜你喜欢

转载自blog.csdn.net/babyshan1/article/details/79798781
pi
今日推荐