[PATCH 1/2] drm/vkms: Refactor vkms_composer_worker() as preparation for virtual HW

Maíra Canal mcanal at igalia.com
Tue May 9 15:05:00 UTC 2023


Add a new function vkms_composer_common(). The actual plane
composition work has been moved to the helper function,
vkms_composer_common(), which is called by vkms_composer_worker() and
will be called in the implementation of the virtual HW mode as well.

Co-developed-by: Sumera Priyadarsini <sylphrenadin at gmail.com>
Signed-off-by: Sumera Priyadarsini <sylphrenadin at gmail.com>
Signed-off-by: Maíra Canal <mcanal at igalia.com>
---
 drivers/gpu/drm/vkms/vkms_composer.c | 38 ++++++++++++++++++----------
 1 file changed, 25 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c
index 906d3df40cdb..f488675ccc62 100644
--- a/drivers/gpu/drm/vkms/vkms_composer.c
+++ b/drivers/gpu/drm/vkms/vkms_composer.c
@@ -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.
 	 */
-- 
2.40.1



More information about the dri-devel mailing list