From patchwork Thu Sep 6 00:18:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepak Singh Rawat X-Patchwork-Id: 10589693 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D442C139B for ; Thu, 6 Sep 2018 00:18:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B2AB02A862 for ; Thu, 6 Sep 2018 00:18:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6CA62A8B4; Thu, 6 Sep 2018 00:18:32 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED 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 50ACC2A862 for ; Thu, 6 Sep 2018 00:18:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 172556E582; Thu, 6 Sep 2018 00:18:30 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from EX13-EDG-OU-002.vmware.com (ex13-edg-ou-002.vmware.com [208.91.0.190]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3603E6E583; Thu, 6 Sep 2018 00:18:29 +0000 (UTC) Received: from sc9-mailhost2.vmware.com (10.113.161.72) by EX13-EDG-OU-002.vmware.com (10.113.208.156) with Microsoft SMTP Server id 15.0.1156.6; Wed, 5 Sep 2018 17:18:21 -0700 Received: from ubuntu.localdomain (promb-2n-dhcp79.eng.vmware.com [10.20.88.79]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 811E5B06D4; Wed, 5 Sep 2018 20:18:28 -0400 (EDT) From: Deepak Rawat To: , , , Subject: [PATCH weston 2/3] compositor-drm: Add support for drm plane FB_DAMAGE_CLIPS property Date: Wed, 5 Sep 2018 17:18:16 -0700 Message-ID: <20180906001817.2585-2-drawat@vmware.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180906001817.2585-1-drawat@vmware.com> References: <20180906001817.2585-1-drawat@vmware.com> MIME-Version: 1.0 Received-SPF: None (EX13-EDG-OU-002.vmware.com: drawat@vmware.com does not designate permitted sender hosts) X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dri-devel@lists.freedesktop.org, Deepak Rawat , lukasz.spintzyk@displaylink.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The plane property FB_DAMAGE_CLIPS provides a way mark damaged regions on the plane in framebuffer coordinates of the framebuffer attached to the plane. This patch adds a new member "damage" to compositor version of drm_plane_state and set FB_DAMAGE_CLIPS property whenever damage is available. Signed-off-by: Deepak Rawat Cc: dri-devel@lists.freedesktop.org --- libweston/compositor-drm.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c index 6a87a296..30f6fce9 100644 --- a/libweston/compositor-drm.c +++ b/libweston/compositor-drm.c @@ -129,6 +129,7 @@ enum wdrm_plane_property { WDRM_PLANE_FB_ID, WDRM_PLANE_CRTC_ID, WDRM_PLANE_IN_FORMATS, + WDRM_PLANE_FB_DAMAGE_CLIPS, WDRM_PLANE__COUNT }; @@ -171,6 +172,7 @@ static const struct drm_property_info plane_props[] = { [WDRM_PLANE_FB_ID] = { .name = "FB_ID", }, [WDRM_PLANE_CRTC_ID] = { .name = "CRTC_ID", }, [WDRM_PLANE_IN_FORMATS] = { .name = "IN_FORMATS" }, + [WDRM_PLANE_FB_DAMAGE_CLIPS] = { .name = "FB_DAMAGE_CLIPS" }, }; /** @@ -403,6 +405,8 @@ struct drm_plane_state { bool complete; + pixman_region32_t damage; /* damage sent to kernel */ + struct wl_list link; /* drm_output_state::plane_list */ }; @@ -1306,6 +1310,7 @@ drm_plane_state_alloc(struct drm_output_state *state_output, assert(state); state->output_state = state_output; state->plane = plane; + pixman_region32_init(&state->damage); /* Here we only add the plane state to the desired link, and not * set the member. Having an output pointer set means that the @@ -1336,6 +1341,7 @@ drm_plane_state_free(struct drm_plane_state *state, bool force) wl_list_remove(&state->link); wl_list_init(&state->link); state->output_state = NULL; + pixman_region32_fini(&state->damage); if (force || state != state->plane->state_cur) { drm_fb_unref(state->fb); @@ -1373,6 +1379,7 @@ drm_plane_state_duplicate(struct drm_output_state *state_output, if (src->fb) dst->fb = drm_fb_ref(src->fb); dst->output_state = state_output; + pixman_region32_init(&dst->damage); dst->complete = false; return dst; @@ -2409,6 +2416,33 @@ drm_mode_ensure_blob(struct drm_backend *backend, struct drm_mode *mode) return ret; } +static int +plane_add_damage(drmModeAtomicReq *req, struct drm_backend *backend, + struct drm_plane_state *plane_state) +{ + struct drm_plane *plane = plane_state->plane; + pixman_box32_t *rects; + uint32_t blob_id; + int n_rects; + int ret; + + if (!pixman_region32_not_empty(&plane_state->damage)) + return 0; + + rects = pixman_region32_rectangles(&plane_state->damage, &n_rects); + + ret = drmModeCreatePropertyBlob(backend->drm.fd, rects, + sizeof(*rects) * n_rects, &blob_id); + if (ret != 0) + return ret; + + ret = plane_add_prop(req, plane, WDRM_PLANE_FB_DAMAGE_CLIPS, blob_id); + if (ret != 0) + return ret; + + return 0; +} + static int drm_output_apply_state_atomic(struct drm_output_state *state, drmModeAtomicReq *req, @@ -2477,6 +2511,7 @@ drm_output_apply_state_atomic(struct drm_output_state *state, plane_state->dest_w); ret |= plane_add_prop(req, plane, WDRM_PLANE_CRTC_H, plane_state->dest_h); + ret |= plane_add_damage(req, backend, plane_state); if (ret != 0) { weston_log("couldn't set plane state\n");