11.2 Android顯示系統框架_android源碼禁用hwc和GPU

2. 修改tiny4412_Android源碼禁用hwc和gpu(廠家不會提供hwc和gpu的源代碼,沒有源代碼就無法分析了,所以在這裏禁用該功能並用軟件庫實現)
最終源碼:
git clone https://github.com/weidongshan/SYS_0003_Patch_Disable_HWC_GPU_tiny4412.git

git clone https://git.coding.net/weidongshan/SYS_0003_Patch_Disable_HWC_GPU.git

更新:
git pull originandroid

取出指定版本:
git checkout v1 // v1, patch to disable HWC&GPU for tiny4412's android-5.0.2

這個補丁作了3件事:
a. 去掉廠家提供的gralloc, hwcopser HAL模塊
b. 添加屬性讓android系統認爲本身運行於"沒有GPU的模擬器"
修改libagl/Android.mk,給系統添加libGLES_android.so (軟件實現的GL)
c. 修改系統自帶的gralloc模塊的BUGgit

 

如何得到HAL模塊gralloc:github

(1)、從哪裏查找文件:/vendor/lib/hw,/system/lib/hw服務器

(2)、文件名是什麼?gralloc.屬性值.so:gralloc.tiny4412.so/gralloc.exynos4.so/gralloc.default.so(gralloc.tiny4412.so就是廠家提供的)composer

 

 

 

修改源碼:
a. 去掉廠家提供的gralloc, hwcopser HAL模塊
a.1 刪除單板上/system/lib/hw(刪除的時候須要執行mount -o remount /system   從新掛載/system後才具備刪除權限)
gralloc.tiny4412.so
hwcomposer.exynos4.so
a.2 修改源碼使得編譯結果中不含上述文件 (修改vendor/friendly-arm/tiny4412/device-tiny4412.mk, 參考補丁110和116行)函數

出錯 : invalid buffer handle givenui

發現出錯的的函數__egl_platform_create_surface_from_native_buffer出錯,但在android系統中搜不到,所以其多是在廠家提供的庫中,.net

在系統中執行grep 「__egl_platform_create_surface_from_native_buffer」 * -nR 發現只在libMali.so中找到,在運行的系統中的/system/lib下搜索Mali相關的庫,找到在/system/lib/egl中,把獲得的libGLES_android.so複製到單板/system/lib/eg/,並添加讀屬性,reboot系統orm

 

b. 添加屬性讓android系統認爲本身運行於"沒有GPU的模擬器"
修改libagl/Android.mk,給系統添加libGLES_android.so (軟件實現的GL)
b.1 添加軟件GPU庫
開發板: su, mount -o remount /system
在服務器編譯軟件GPU庫: mmm frameworks/native/opengl/libagl   //執行mmm命令後會獲得libGLES_android.so
把獲得的libGLES_android.so複製到單板/system/lib/eg/,並添加讀屬性chmod 777 libGLES_android.so開發

b.2 修改frameworks/native/opengl/libagl/Android.mk (參考補丁)

b.3 修改屬性文件 , 單板 /system/build.prop,添加:
ro.kernel.qemu=1
ro.kernel.qemu.gles=0

或修改源碼 device/friendly-arm/tiny4412/system.prop 一樣添加上述屬性, 而後從新編譯系統

從新啓動後出錯: no suitable EGLConfig found, giving up

c. 修改系統自帶的gralloc模塊的BUG
c.1 修改 hardware\libhardware\modules\gralloc\Framebuffer.cpp
HAL_PIXEL_FORMAT_BGRA_8888
改成:
HAL_PIXEL_FORMAT_RGBA_8888

mmm hardware/libhardware/modules/gralloc/
把gralloc.default.so複製到單板/system/lib/hw

重啓,出錯:BufferQueueProducer( 2320): [FramebufferSurface] dequeueBuffer: createGraphicBuffer failed
W/GraphicBufferAllocator( 1918): alloc(800, 480, 1, 00001a33, ...) failed -12 (Out of memory)
c.2 繼續修改 hardware\libhardware\modules\gralloc\Framebuffer.cpp
mmm hardware/libhardware/modules/gralloc/
把gralloc.default.so複製到單板/system/lib/hw

成功!

相關文章
相關標籤/搜索