@@ -212,6 +212,30 @@ static int compose_active_planes(struct vkms_writeback_job *active_wb,
return ret;
}
+static int vkms_composer_common(struct vkms_crtc_state *crtc_state,
+ struct vkms_output *out, bool wb_pending, uint32_t *crc32)
+{
+ struct vkms_writeback_job *active_wb = crtc_state->active_writeback;
+ int ret;
+
+ if (wb_pending)
+ ret = compose_active_planes(active_wb, crtc_state, crc32);
+ else
+ ret = compose_active_planes(NULL, crtc_state, crc32);
+
+ if (ret)
+ return ret;
+
+ if (wb_pending) {
+ drm_writeback_signal_completion(&out->wb_connector, 0);
+ spin_lock_irq(&out->composer_lock);
+ crtc_state->wb_pending = false;
+ spin_unlock_irq(&out->composer_lock);
+ }
+
+ return 0;
+}
+
/**
* vkms_composer_worker - ordered work_struct to compute CRC
*
@@ -227,7 +251,6 @@ void vkms_composer_worker(struct work_struct *work)
struct vkms_crtc_state,
composer_work);
struct drm_crtc *crtc = crtc_state->base.crtc;
- struct vkms_writeback_job *active_wb = crtc_state->active_writeback;
struct vkms_output *out = drm_crtc_to_vkms_output(crtc);
bool crc_pending, wb_pending;
u64 frame_start, frame_end;
@@ -251,21 +274,10 @@ void vkms_composer_worker(struct work_struct *work)
if (!crc_pending)
return;
- if (wb_pending)
- ret = compose_active_planes(active_wb, crtc_state, &crc32);
- else
- ret = compose_active_planes(NULL, crtc_state, &crc32);
-
+ ret = vkms_composer_common(crtc_state, out, wb_pending, &crc32);
if (ret)
return;
- if (wb_pending) {
- drm_writeback_signal_completion(&out->wb_connector, 0);
- spin_lock_irq(&out->composer_lock);
- crtc_state->wb_pending = false;
- spin_unlock_irq(&out->composer_lock);
- }
-
/*
* The worker can fall behind the vblank hrtimer, make sure we catch up.
*/