From: Hyungwon Hwang <human.hwang@samsung.com>
To: dri-devel@lists.freedesktop.org, human.hwang@samsung.com
Subject: [PATCH 2/6] xf86drmMode: separate drmModeAtomicCommit() and drmModeAtomicCleanup()
Date: Wed, 19 Aug 2015 09:58:40 +0900 [thread overview]
Message-ID: <1439945924-22630-2-git-send-email-human.hwang@samsung.com> (raw)
In-Reply-To: <1439945924-22630-1-git-send-email-human.hwang@samsung.com>
This patch seprates the code, which sorts proprty sets and eliminates
duplicate properties, from drmModeAtomicCommit(). Now
drmModeAtomicCleanup() has to do the job before calling
drmModeAtomicCommit(), and drmModeAtomicCommit() just converts the cleaned
request to IOCTL argument.
Signed-off-by: Hyungwon Hwang <human.hwang@samsung.com>
---
xf86drmMode.c | 72 +++++++++++++++++++++++++++++++++--------------------------
xf86drmMode.h | 1 +
2 files changed, 41 insertions(+), 32 deletions(-)
diff --git a/xf86drmMode.c b/xf86drmMode.c
index d4ed5c1..82c4c91 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -1303,10 +1303,39 @@ static int sort_req_list(const void *misc, const void *other)
return second->property_id - first->property_id;
}
+void drmModeAtomicCleanup(drmModeAtomicReqPtr req)
+{
+ uint32_t last_obj_id = 0;
+ uint32_t i;
+
+ if (req->cursor == 0)
+ return;
+
+ /* Sort the list by object ID, then by property ID. */
+ qsort(req->items, req->cursor, sizeof(*req->items),
+ sort_req_list);
+
+ /* Eliminate duplicate property sets. */
+ for (i = 0; i < req->cursor; i++) {
+ if (req->items[i].object_id != last_obj_id)
+ last_obj_id = req->items[i].object_id;
+
+ if (i == req->cursor - 1)
+ continue;
+
+ if (req->items[i].object_id != req->items[i + 1].object_id ||
+ req->items[i].property_id != req->items[i + 1].property_id)
+ continue;
+
+ memmove(&req->items[i], &req->items[i + 1],
+ (req->cursor - i - 1) * sizeof(*req->items));
+ req->cursor--;
+ }
+}
+
int drmModeAtomicCommit(int fd, drmModeAtomicReqPtr req, uint32_t flags,
void *user_data)
{
- drmModeAtomicReqPtr sorted;
struct drm_mode_atomic atomic;
uint32_t *objs_ptr = NULL;
uint32_t *count_props_ptr = NULL;
@@ -1320,33 +1349,13 @@ int drmModeAtomicCommit(int fd, drmModeAtomicReqPtr req, uint32_t flags,
if (req->cursor == 0)
return 0;
- sorted = drmModeAtomicDuplicate(req);
- if (sorted == NULL)
- return -ENOMEM;
-
memclear(atomic);
- /* Sort the list by object ID, then by property ID. */
- qsort(sorted->items, sorted->cursor, sizeof(*sorted->items),
- sort_req_list);
-
- /* Now the list is sorted, eliminate duplicate property sets. */
- for (i = 0; i < sorted->cursor; i++) {
- if (sorted->items[i].object_id != last_obj_id) {
+ for (i = 0; i < req->cursor; i++) {
+ if (req->items[i].object_id != last_obj_id) {
atomic.count_objs++;
- last_obj_id = sorted->items[i].object_id;
+ last_obj_id = req->items[i].object_id;
}
-
- if (i == sorted->cursor - 1)
- continue;
-
- if (sorted->items[i].object_id != sorted->items[i + 1].object_id ||
- sorted->items[i].property_id != sorted->items[i + 1].property_id)
- continue;
-
- memmove(&sorted->items[i], &sorted->items[i + 1],
- (sorted->cursor - i - 1) * sizeof(*sorted->items));
- sorted->cursor--;
}
objs_ptr = drmMalloc(atomic.count_objs * sizeof objs_ptr[0]);
@@ -1361,28 +1370,28 @@ int drmModeAtomicCommit(int fd, drmModeAtomicReqPtr req, uint32_t flags,
goto out;
}
- props_ptr = drmMalloc(sorted->cursor * sizeof props_ptr[0]);
+ props_ptr = drmMalloc(req->cursor * sizeof props_ptr[0]);
if (!props_ptr) {
errno = ENOMEM;
goto out;
}
- prop_values_ptr = drmMalloc(sorted->cursor * sizeof prop_values_ptr[0]);
+ prop_values_ptr = drmMalloc(req->cursor * sizeof prop_values_ptr[0]);
if (!prop_values_ptr) {
errno = ENOMEM;
goto out;
}
- for (i = 0, last_obj_id = 0; i < sorted->cursor; i++) {
- if (sorted->items[i].object_id != last_obj_id) {
+ for (i = 0, last_obj_id = 0; i < req->cursor; i++) {
+ if (req->items[i].object_id != last_obj_id) {
obj_idx++;
- objs_ptr[obj_idx] = sorted->items[i].object_id;
+ objs_ptr[obj_idx] = req->items[i].object_id;
last_obj_id = objs_ptr[obj_idx];
}
count_props_ptr[obj_idx]++;
- props_ptr[i] = sorted->items[i].property_id;
- prop_values_ptr[i] = sorted->items[i].value;
+ props_ptr[i] = req->items[i].property_id;
+ prop_values_ptr[i] = req->items[i].value;
}
@@ -1400,7 +1409,6 @@ out:
drmFree(count_props_ptr);
drmFree(props_ptr);
drmFree(prop_values_ptr);
- drmModeAtomicFree(sorted);
return ret;
}
diff --git a/xf86drmMode.h b/xf86drmMode.h
index 4de7bbb..fe14078 100644
--- a/xf86drmMode.h
+++ b/xf86drmMode.h
@@ -498,6 +498,7 @@ extern int drmModeAtomicAddProperty(drmModeAtomicReqPtr req,
uint32_t object_id,
uint32_t property_id,
uint64_t value);
+extern void drmModeAtomicCleanup(drmModeAtomicReqPtr req);
extern int drmModeAtomicCommit(int fd,
drmModeAtomicReqPtr req,
uint32_t flags,
--
2.4.3
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2015-08-19 0:58 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-19 0:58 [PATCH 1/6] xf86drmMode: remove the trailing white spaces Hyungwon Hwang
2015-08-19 0:58 ` Hyungwon Hwang [this message]
2015-08-20 16:17 ` [PATCH 2/6] xf86drmMode: separate drmModeAtomicCommit() and drmModeAtomicCleanup() Emil Velikov
2015-08-21 4:54 ` Hyungwon Hwang
2015-08-21 6:42 ` Pekka Paalanen
2015-08-21 7:18 ` Hyungwon Hwang
2015-08-21 10:08 ` Pekka Paalanen
2015-08-19 0:58 ` [PATCH 3/6] xf86drmMode: Make atomic request structures visible Hyungwon Hwang
2015-08-20 16:23 ` Emil Velikov
2015-08-21 6:06 ` Hyungwon Hwang
2015-08-21 6:44 ` Pekka Paalanen
2015-08-21 7:35 ` Hyungwon Hwang
2015-08-19 0:58 ` [PATCH 4/6] modetest: remove the trailing white spaces Hyungwon Hwang
2015-08-19 0:58 ` [PATCH 5/6] modetest: add atomic modeset support Hyungwon Hwang
2015-08-19 0:58 ` [PATCH 6/6] modetest: add atomic page flip support Hyungwon Hwang
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=1439945924-22630-2-git-send-email-human.hwang@samsung.com \
--to=human.hwang@samsung.com \
--cc=dri-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