顯示廣告
隱藏 ✕
看板 million
作者 emulators (模擬器)
標題 [note] 作業 power management 做法紀錄
時間 2014年10月08日 Wed. PM 08:56:15


請用一步驟讓模擬器真的 suspend, 然後用 dmesg 確認自己的 driver 有進入 early suspend > suspend > resume > late resume 流程.

解:
為了註冊 register_early_suspend( struct early_suspend *handler ) 這個函式,
需要宣告一個 struct early_suspend *handler 物件以給該函式指標.
故使用 global structure,
在 driver probe function 中依序給這個 struct 應有的 level 值.
另外, 為了使 early_suspend 以及 late-resume 確實寫 kernel message,
需要另外定義這兩個 function. 並在此二個 function 中使用 printk.

這麼一來, 在 probe function 中就可以確實給 handler 值, 並呼叫 register_early_suspend function.

另外, platform device 也需要另外把 .suspend 及 .resume 二個函式指向自訂的 suspend/resume 函式內.
故定義好 suspend/resume 函式並在其中都加入 printk 訊息, 重新編譯 kernel 即完成一半.

接下來只要開模擬器進 adb shell, 先按電源鈕使模擬器進入 early suspend 狀態,
用 echo "PowerManagerService" > /sys/power/wake_unlock 把剩下的 wakelock 拿掉,
模擬器即完全進入 suspend 狀態. 再按一次電源鈕使其喚醒, 看 dmseg 即知道有無成功.

--
※ 作者: emulators 時間: 2014-10-08 20:56:15
※ 看板: million 文章推薦值: 0 目前人氣: 0 累積人氣: 223 
r)回覆 e)編輯 d)刪除 M)收藏 ^x)轉錄 同主題: =)首篇 [)上篇 ])下篇