summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/modetest/modetest.c53
1 files changed, 47 insertions, 6 deletions
diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index a5ac5bd..f7d1511 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -172,6 +172,8 @@ static const char *mode_flag_names[] = {
"clkdiv2"
};
+static bool use_atomic;
+
static bit_name_fn(mode_flag)
static void dump_encoders(struct device *dev)
@@ -514,13 +516,17 @@ static void free_resources(struct resources *res)
static struct resources *get_resources(struct device *dev)
{
struct resources *res;
- int i;
+ int i, ret;
res = calloc(1, sizeof(*res));
if (res == 0)
return NULL;
- drmSetClientCap(dev->fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
+ ret = drmSetClientCap(dev->fd, DRM_CLIENT_CAP_ATOMIC, 1);
+ if (!ret)
+ use_atomic = true;
+ else
+ drmSetClientCap(dev->fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1);
res->res = drmModeGetResources(dev->fd);
if (!res->res) {
@@ -1025,7 +1031,7 @@ static int set_plane(struct device *dev, struct plane_arg *p)
/* note src coords (last 4 args) are in Q16 format */
if (drmModeSetPlane(dev->fd, plane_id, crtc->crtc->crtc_id, p->fb_id,
plane_flags, crtc_x, crtc_y, crtc_w, crtc_h,
- 0, 0, p->w << 16, p->h << 16)) {
+ 1, 0, p->w << 16, p->h << 16)) {
fprintf(stderr, "failed to enable plane: %s\n",
strerror(errno));
return -1;
@@ -1129,16 +1135,51 @@ static void clear_mode(struct device *dev)
bo_destroy(dev->mode.bo);
}
-static void set_planes(struct device *dev, struct plane_arg *p, unsigned int count)
+static void populate_atomic_req(struct device *dev, drmModeAtomicReq *req,
+ struct plane_arg *p, unsigned int count)
{
- unsigned int i;
+ int i;
- /* set up planes/overlays */
+ //for each plane
for (i = 0; i < count; i++)
+ // find crtc
+ //
+ // find available plane
+ //
+ // add fb
+ //
+ // set props: crtc_id, fb_id, src_*, crtc_*
if (set_plane(dev, &p[i]))
return;
}
+static void atomic_commit(struct device *dev, struct plane_arg *p, unsigned int count)
+{
+ drmModeAtomicReq *req;
+
+ req = drmModeAtomicAlloc();
+
+ populate_atomic_req(dev, req, p, count);
+
+ drmModeAtomicCommit(dev->fd, req, <flags>, <output>);
+
+ drmModeAtomicFree(req);
+}
+
+static void set_planes(struct device *dev, struct plane_arg *p, unsigned int count)
+{
+ unsigned int i;
+
+ if (use_atomic) {
+ set_atomic(dev, p, count);
+ } else {
+ /* set up planes/overlays */
+ for (i = 0; i < count; i++)
+ if (set_plane(dev, &p[i]))
+ return;
+ }
+}
+
static void set_cursors(struct device *dev, struct pipe_arg *pipes, unsigned int count)
{
uint32_t handles[4] = {0}, pitches[4] = {0}, offsets[4] = {0};