diff --git a/libweston/backend-drm/drm-internal.h b/libweston/backend-drm/drm-internal.h index 22b5fa35cdc0eb6a6c98b729666d795dba00ef5a..affea5cf940381f99dee0fe534c02099d55c1b82 100755 --- a/libweston/backend-drm/drm-internal.h +++ b/libweston/backend-drm/drm-internal.h @@ -307,6 +307,7 @@ struct drm_backend { bool use_tde; // OHOS fix pthread_t vsync_thread; // OHOS vsync module bool vsync_thread_running; // OHOS vsync module + int pipe; // OHOS vsync module }; struct drm_mode { diff --git a/libweston/backend-drm/drm.c b/libweston/backend-drm/drm.c index 0eaf2a9fac8cbb18fc20d1caa28c47d7a8720d17..cf14f71492649820a9ec439e6eda56970bd18ccb 100755 --- a/libweston/backend-drm/drm.c +++ b/libweston/backend-drm/drm.c @@ -524,6 +524,17 @@ drm_waitvblank_pipe(struct drm_output *output) return 0; } +static unsigned int +drm_waitvblank_pipe_vsync(int pipe) +{ + if (pipe > 1) + return (pipe << DRM_VBLANK_HIGH_CRTC_SHIFT) & + DRM_VBLANK_HIGH_CRTC_MASK; + else if (pipe > 0) + return DRM_VBLANK_SECONDARY; + else + return 0; +} static int drm_output_start_repaint_loop(struct weston_output *output_base) { @@ -1644,6 +1655,7 @@ drm_output_init_crtc(struct drm_output *output, drmModeRes *resources) output->crtc_id = resources->crtcs[i]; output->pipe = i; + b->pipe = i; props = drmModeObjectGetProperties(b->drm.fd, output->crtc_id, DRM_MODE_OBJECT_CRTC); @@ -2859,13 +2871,14 @@ ohos_drm_vsync_thread_main(void *backend) while (b->vsync_thread_running) { drmVBlank vbl = { .request = { - .type = DRM_VBLANK_RELATIVE, + .type = DRM_VBLANK_RELATIVE | drm_waitvblank_pipe_vsync(b->pipe), .sequence = 1, }, }; if (drmWaitVBlank(b->drm.fd, &vbl) != 0) { - weston_log("Failed to drmWaitVBlank (the first vblank event), because %{public}d", errno); + //weston_log("Failed to drmWaitVBlank (the first vblank event), because %{public}d", errno); sleep(0); + VsyncModuleTrigger(); } else { VsyncModuleTrigger(); }