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 virtual_hw mode as well. Signed-off-by: Sumera Priyadarsini <sylphrenadin@xxxxxxxxx> --- Changes in V5: - Move vkms_crtc_composer() to the patch that introduces virtual_hw mode (Melissa) - Fix checkpatch errors(Melissa) Changes in V4: - Fix warning Changes in V3: - Refactor patchset (Melissa) Change in V2: - Add vkms_composer_common() (Daniel) --- drivers/gpu/drm/vkms/vkms_composer.c | 75 ++++++++++++++++------------ drivers/gpu/drm/vkms/vkms_drv.h | 2 + 2 files changed, 45 insertions(+), 32 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c index 9e8204be9a14..bca746fb5b53 100644 --- a/drivers/gpu/drm/vkms/vkms_composer.c +++ b/drivers/gpu/drm/vkms/vkms_composer.c @@ -206,6 +206,47 @@ static int compose_active_planes(void **vaddr_out, return 0; } +int vkms_composer_common(struct vkms_crtc_state *crtc_state, + struct vkms_output *out, bool wb_pending, uint32_t *crc32) +{ + struct vkms_composer *primary_composer = NULL; + struct vkms_plane_state *act_plane = NULL; + void *vaddr_out = NULL; + int ret; + + if (crtc_state->num_active_planes >= 1) { + act_plane = crtc_state->active_planes[0]; + if (act_plane->base.base.plane->type == DRM_PLANE_TYPE_PRIMARY) + primary_composer = act_plane->composer; + } + + if (!primary_composer) + return -EINVAL; + if (wb_pending) + vaddr_out = crtc_state->active_writeback->data[0].vaddr; + + ret = compose_active_planes(&vaddr_out, primary_composer, crtc_state); + + if (ret) { + if ((ret == -EINVAL || ret == -ENOMEM) && !wb_pending) + kfree(vaddr_out); + return ret; + } + + *crc32 = compute_crc(vaddr_out, primary_composer); + + 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); + } else { + kfree(vaddr_out); + } + + return 0; +} + /** * vkms_composer_worker - ordered work_struct to compute CRC * @@ -222,10 +263,7 @@ void vkms_composer_worker(struct work_struct *work) composer_work); struct drm_crtc *crtc = crtc_state->base.crtc; struct vkms_output *out = drm_crtc_to_vkms_output(crtc); - struct vkms_composer *primary_composer = NULL; - struct vkms_plane_state *act_plane = NULL; bool crc_pending, wb_pending; - void *vaddr_out = NULL; u32 crc32 = 0; u64 frame_start, frame_end; int ret; @@ -247,37 +285,10 @@ void vkms_composer_worker(struct work_struct *work) if (!crc_pending) return; - if (crtc_state->num_active_planes >= 1) { - act_plane = crtc_state->active_planes[0]; - if (act_plane->base.base.plane->type == DRM_PLANE_TYPE_PRIMARY) - primary_composer = act_plane->composer; - } - - if (!primary_composer) + ret = vkms_composer_common(crtc_state, out, wb_pending, &crc32); + if (ret == -EINVAL) return; - if (wb_pending) - vaddr_out = crtc_state->active_writeback->data[0].vaddr; - - ret = compose_active_planes(&vaddr_out, primary_composer, - crtc_state); - if (ret) { - if (ret == -EINVAL && !wb_pending) - kfree(vaddr_out); - return; - } - - crc32 = compute_crc(vaddr_out, primary_composer); - - 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); - } else { - kfree(vaddr_out); - } - /* * The worker can fall behind the vblank hrtimer, make sure we catch up. */ diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h index d48c23d40ce5..6f5f63591c20 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -137,6 +137,8 @@ int vkms_verify_crc_source(struct drm_crtc *crtc, const char *source_name, size_t *values_cnt); /* Composer Support */ +int vkms_composer_common(struct vkms_crtc_state *crtc_state, struct vkms_output *out, + bool wb_pending, uint32_t *crcs); void vkms_composer_worker(struct work_struct *work); void vkms_set_composer(struct vkms_output *out, bool enabled); -- 2.31.1