From patchwork Fri May 12 19:10:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gustavo Padovan X-Patchwork-Id: 9724793 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 92E26601E7 for ; Fri, 12 May 2017 19:11:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B1D528831 for ; Fri, 12 May 2017 19:11:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7FF892886D; Fri, 12 May 2017 19:11:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.7 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 31E3028831 for ; Fri, 12 May 2017 19:11:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EC8888932A; Fri, 12 May 2017 19:11:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt0-f194.google.com (mail-qt0-f194.google.com [209.85.216.194]) by gabe.freedesktop.org (Postfix) with ESMTPS id A498F6E704 for ; Fri, 12 May 2017 19:11:04 +0000 (UTC) Received: by mail-qt0-f194.google.com with SMTP id r58so7937432qtb.2 for ; Fri, 12 May 2017 12:11:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/gNijny5BCbQQr+pQ/uZdgzRjMkdycIm3S+L92IDj30=; b=jtsmysYAPICKZEWmP8xJH0zupNkoWDiE6iJ0pMwm+tEKLDgKV80XGiSKd4wa5n/RkT pek3tcEuXdGVu5slKEUB9tOvbn9U2JSX1KMwP49D3CNRhCqGhI8EJWKA+dA2BOKfn9jL xalmY0hjMXEDYOgpcMICmgYvzPbbnxbAARc2IU/N2BY/CxLMkEaW4Sj5RbsHOLOcSF/o vYCdsG8Dymhc6yAC1NoQkJ0xnuzYLLacGPOkwsq+NI4xQ0AHsB7XdFaNwZ0bNg7QZs/3 zhbJDg+46gs3xEvLw60yB6BaYSon4ptdaL6eLrARGu/4GP33AnC8uPDPXXyg8j5Hbssi +GPA== X-Gm-Message-State: AODbwcBCM2Mvz+PI54ySUMx9Lrd97e+iGUVHAlse2SEQVHs71jbZA2ie NgifkUCE56RD5AK1phc= X-Received: by 10.200.48.80 with SMTP id g16mr5783269qte.78.1494616263637; Fri, 12 May 2017 12:11:03 -0700 (PDT) Received: from localhost.localdomain ([177.17.166.160]) by smtp.gmail.com with ESMTPSA id g32sm2930406qtc.19.2017.05.12.12.11.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 May 2017 12:11:03 -0700 (PDT) From: Gustavo Padovan To: dri-devel@lists.freedesktop.org Subject: [RFC v3 2/8] drm/virtio: support async cursor updates Date: Fri, 12 May 2017 16:10:48 -0300 Message-Id: <20170512191054.10074-3-gustavo@padovan.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170512191054.10074-1-gustavo@padovan.org> References: <20170512191054.10074-1-gustavo@padovan.org> Cc: Gustavo Padovan X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Gustavo Padovan Short circuit the update path for cursors and use the drm async update infrastructure. v2: move fb setting to core and use new state (Eric Anholt) Signed-off-by: Gustavo Padovan --- I wrote this mostly for testing purposes, not sure if its something that we actually need for virtio. --- drivers/gpu/drm/virtio/virtgpu_plane.c | 53 ++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c b/drivers/gpu/drm/virtio/virtgpu_plane.c index 76d5fed..9b396c1 100644 --- a/drivers/gpu/drm/virtio/virtgpu_plane.c +++ b/drivers/gpu/drm/virtio/virtgpu_plane.c @@ -260,6 +260,57 @@ static void virtio_gpu_cursor_plane_update(struct drm_plane *plane, virtio_gpu_cursor_ping(vgdev, output); } +static int virtio_gpu_cursor_plane_async_check(struct drm_plane *plane, + struct drm_plane_state *new_state) +{ + struct virtio_gpu_output *output; + + if (!plane->state->crtc) + return -EINVAL; + + output = drm_crtc_to_virtio_gpu_output(plane->state->crtc); + if (!output) + return -EINVAL; + + if (plane->state->crtc != new_state->crtc || + plane->state->src_w != new_state->src_w || + plane->state->src_h != new_state->src_h || + plane->state->crtc_w != new_state->crtc_w || + plane->state->crtc_h != new_state->crtc_h || + !plane->state->fb || + plane->state->fb != new_state->fb) + return -EINVAL; + + return 0; +} + +static void virtio_gpu_cursor_plane_async_update(struct drm_plane *plane, + struct drm_plane_state *new_state) +{ + struct drm_device *dev = plane->dev; + struct virtio_gpu_device *vgdev = dev->dev_private; + struct virtio_gpu_output *output = NULL; + + output = drm_crtc_to_virtio_gpu_output(plane->state->crtc); + if (WARN_ON(!output)) + return; + + if (plane->state->fb != new_state->fb) + return; + + plane->state->src_x = new_state->src_x; + plane->state->src_y = new_state->src_y; + plane->state->crtc_x = new_state->crtc_x; + plane->state->crtc_y = new_state->crtc_y; + + DRM_DEBUG("move +%d+%d\n", plane->state->crtc_x, plane->state->crtc_y); + + output->cursor.hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_MOVE_CURSOR); + output->cursor.pos.x = cpu_to_le32(plane->state->crtc_x); + output->cursor.pos.y = cpu_to_le32(plane->state->crtc_y); + virtio_gpu_cursor_ping(vgdev, output); +} + static const struct drm_plane_helper_funcs virtio_gpu_primary_helper_funcs = { .atomic_check = virtio_gpu_plane_atomic_check, .atomic_update = virtio_gpu_primary_plane_update, @@ -268,6 +319,8 @@ static const struct drm_plane_helper_funcs virtio_gpu_primary_helper_funcs = { static const struct drm_plane_helper_funcs virtio_gpu_cursor_helper_funcs = { .atomic_check = virtio_gpu_plane_atomic_check, .atomic_update = virtio_gpu_cursor_plane_update, + .atomic_async_check = virtio_gpu_cursor_plane_async_check, + .atomic_async_update = virtio_gpu_cursor_plane_async_update, }; struct drm_plane *virtio_gpu_plane_init(struct virtio_gpu_device *vgdev,