手機 - Motorola XT897 - Sailfish OS - 為何Framebuffer更新很慢



drivers/video/msm/msm_fb.c

2014 static int msm_fb_pan_display(struct fb_var_screeninfo *var,
2015                   struct fb_info *info)
2016 {
2017     struct mdp_display_commit disp_commit;
2018     memset(&disp_commit, 0, sizeof(disp_commit));
2019     disp_commit.var = *var;
2020     disp_commit.wait_for_finish = TRUE;
2021     return msm_fb_pan_display_ex(info, &disp_commit);
2022 }

disp_commit.wait_for_finish的設定值會決定是否須等待完成

1992     if (wait_for_finish)
1993         msm_fb_pan_idle(mfd);
1994     return ret;

比較好的作法是使用FBIO_WAITFORVSYNC,而在FBIOPAN_DISPLAY時,先將控制權交還User Application

1904 DEFINE_SEMAPHORE(msm_fb_pan_sem);
1905 static int msm_fb_pan_idle(struct msm_fb_data_type *mfd)
1906 {
1907     int ret = 0;
1908
1909     mutex_lock(&mfd->sync_mutex);
1910     if (mfd->is_committing) {
1911         mutex_unlock(&mfd->sync_mutex);
1912         ret = wait_for_completion_interruptible_timeout(
1913                 &mfd->commit_comp,
1914             msecs_to_jiffies(WAIT_DISP_OP_TIMEOUT));
1915         if (ret < 0)
1916             ret = -ERESTARTSYS;
1917         else if (!ret)
1918             pr_err("%s wait for commit_comp timeout %d %d",
1919                 __func__, ret, mfd->is_committing);
1920         if (ret <= 0) {
1921             mutex_lock(&mfd->sync_mutex);
1922             mfd->is_committing = 0;
1923             complete_all(&mfd->commit_comp);
1924             mutex_unlock(&mfd->sync_mutex);
1925         }
1926     } else {
1927         mutex_unlock(&mfd->sync_mutex);
1928     }
1929     return ret;
1930 }