dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Deepak Rawat <drawat@vmware.com>
To: wayland-devel@lists.freedesktop.org,
	linux-graphics-maintainer@vmware.com, thellstrom@vmware.com,
	syeh@vmware.com
Cc: dri-devel@lists.freedesktop.org, Deepak Rawat <drawat@vmware.com>,
	lukasz.spintzyk@displaylink.com
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	[thread overview]
Message-ID: <20180906001817.2585-2-drawat@vmware.com> (raw)
In-Reply-To: <20180906001817.2585-1-drawat@vmware.com>

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 <drawat@vmware.com>
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");
-- 
2.17.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

       reply	other threads:[~2018-09-06  0:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20180906001817.2585-1-drawat@vmware.com>
2018-09-06  0:18 ` Deepak Rawat [this message]
2018-09-06  7:25   ` [PATCH weston 2/3] compositor-drm: Add support for drm plane FB_DAMAGE_CLIPS property Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180906001817.2585-2-drawat@vmware.com \
    --to=drawat@vmware.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-graphics-maintainer@vmware.com \
    --cc=lukasz.spintzyk@displaylink.com \
    --cc=syeh@vmware.com \
    --cc=thellstrom@vmware.com \
    --cc=wayland-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox