Banana Pi M64 Android修改分辨率为480x1280横屏显示
16lz
2021-01-23
由于项目需要,使用了一块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_60HZ和 DISP_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;
经过以上修改后,重新编译内核和源码,终于可以正常横屏显示了,希望能帮到有同样问题的朋友。
更多相关文章
- Android使用xutils3框架实现应用程序内的检查更新下载服务器存放
- Android清单文件详解(一) ---- 一切从开始
- Android Studio SDK版本兼容问题,拷贝的Android包文件报错
- Android工程源文件结构
- 修改默认配置文件.android.gradle.androidstudio到其他目录
- Android 资源文件使用方法详解
- Android使用XML文件定义用户界面