From patchwork Fri Jun 14 21:21:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2724861 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5C109C0AB1 for ; Fri, 14 Jun 2013 21:36:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 555E620357 for ; Fri, 14 Jun 2013 21:36:37 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 5823E2034A for ; Fri, 14 Jun 2013 21:36:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 56F83E611C for ; Fri, 14 Jun 2013 14:36:36 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [95.142.166.194]) by gabe.freedesktop.org (Postfix) with ESMTP id 9E80FE5DBC for ; Fri, 14 Jun 2013 14:21:38 -0700 (PDT) Received: from avalon.ideasonboard.com (unknown [91.177.128.27]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 54CB535A4F; Fri, 14 Jun 2013 23:21:28 +0200 (CEST) From: Laurent Pinchart To: dri-devel@lists.freedesktop.org Subject: [PATCH v5 18/23] modetest: Split mode setting and plane setup Date: Fri, 14 Jun 2013 23:21:29 +0200 Message-Id: <1371244894-27878-19-git-send-email-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 1.8.1.5 In-Reply-To: <1371244894-27878-1-git-send-email-laurent.pinchart@ideasonboard.com> References: <1371244894-27878-1-git-send-email-laurent.pinchart@ideasonboard.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There's not reason to require setting a mode to test planes. Split the two operations. Signed-off-by: Laurent Pinchart --- tests/modetest/modetest.c | 106 +++++++++++++++++++++++++++++++--------------- 1 file changed, 73 insertions(+), 33 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 0dfdaa5..adbd073 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -101,6 +101,14 @@ struct device { struct resources *resources; struct kms_driver *kms; + + struct { + unsigned int width; + unsigned int height; + + unsigned int fb_id; + struct kms_bo *bo; + } mode; }; #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) @@ -840,7 +848,7 @@ static int set_plane(struct device *dev, struct plane_arg *p) struct kms_bo *plane_bo; uint32_t plane_flags = 0; int crtc_x, crtc_y, crtc_w, crtc_h; - struct crtc *crtc; + struct crtc *crtc = NULL; unsigned int pipe; unsigned int i; @@ -915,36 +923,37 @@ static int set_plane(struct device *dev, struct plane_arg *p) return 0; } -static void set_mode(struct device *dev, struct connector_arg *c, int count, - struct plane_arg *p, int plane_count, int page_flip) +static void set_mode(struct device *dev, struct connector_arg *c, unsigned int count) { - struct kms_bo *bo, *other_bo; - unsigned int fb_id, other_fb_id; - int i, j, ret, width, height, x; uint32_t handles[4], pitches[4], offsets[4] = {0}; /* we only use [0] */ - drmEventContext evctx; + unsigned int fb_id; + struct kms_bo *bo; + unsigned int i; + int ret, x; + + dev->mode.width = 0; + dev->mode.height = 0; - width = 0; - height = 0; for (i = 0; i < count; i++) { connector_find_mode(dev, &c[i]); if (c[i].mode == NULL) continue; - width += c[i].mode->hdisplay; - if (height < c[i].mode->vdisplay) - height = c[i].mode->vdisplay; + dev->mode.width += c[i].mode->hdisplay; + if (dev->mode.height < c[i].mode->vdisplay) + dev->mode.height = c[i].mode->vdisplay; } - bo = create_test_buffer(dev->kms, c->fourcc, width, height, handles, - pitches, offsets, PATTERN_SMPTE); + bo = create_test_buffer(dev->kms, c->fourcc, + dev->mode.width, dev->mode.height, + handles, pitches, offsets, PATTERN_SMPTE); if (bo == NULL) return; - ret = drmModeAddFB2(dev->fd, width, height, c->fourcc, + ret = drmModeAddFB2(dev->fd, dev->mode.width, dev->mode.height, c->fourcc, handles, pitches, offsets, &fb_id, 0); if (ret) { fprintf(stderr, "failed to add fb (%ux%u): %s\n", - width, height, strerror(errno)); + dev->mode.width, dev->mode.height, strerror(errno)); return; } @@ -968,24 +977,39 @@ static void set_mode(struct device *dev, struct connector_arg *c, int count, fprintf(stderr, "failed to set mode: %s\n", strerror(errno)); return; } - - /* if we have a plane/overlay to show, set that up now: */ - for (j = 0; j < plane_count; j++) - if (p[j].crtc_id == c[i].crtc_id) - if (set_plane(dev, &p[j])) - return; } - if (!page_flip) - return; + dev->mode.bo = bo; + dev->mode.fb_id = fb_id; +} + +static void set_planes(struct device *dev, struct plane_arg *p, unsigned int count) +{ + unsigned int i; + + /* set up planes/overlays */ + for (i = 0; i < count; i++) + if (set_plane(dev, &p[i])) + return; +} - other_bo = create_test_buffer(dev->kms, c->fourcc, width, height, handles, - pitches, offsets, PATTERN_PLAIN); +static void test_page_flip(struct device *dev, struct connector_arg *c, unsigned int count) +{ + uint32_t handles[4], pitches[4], offsets[4] = {0}; /* we only use [0] */ + unsigned int other_fb_id; + struct kms_bo *other_bo; + drmEventContext evctx; + unsigned int i; + int ret; + + other_bo = create_test_buffer(dev->kms, c->fourcc, + dev->mode.width, dev->mode.height, + handles, pitches, offsets, PATTERN_PLAIN); if (other_bo == NULL) return; - ret = drmModeAddFB2(dev->fd, width, height, c->fourcc, handles, pitches, offsets, - &other_fb_id, 0); + ret = drmModeAddFB2(dev->fd, dev->mode.width, dev->mode.height, c->fourcc, + handles, pitches, offsets, &other_fb_id, 0); if (ret) { fprintf(stderr, "failed to add fb: %s\n", strerror(errno)); return; @@ -1003,7 +1027,7 @@ static void set_mode(struct device *dev, struct connector_arg *c, int count, } gettimeofday(&c[i].start, NULL); c[i].swap_count = 0; - c[i].fb_id[0] = fb_id; + c[i].fb_id[0] = dev->mode.fb_id; c[i].fb_id[1] = other_fb_id; c[i].current_fb_id = other_fb_id; } @@ -1051,7 +1075,6 @@ static void set_mode(struct device *dev, struct connector_arg *c, int count, drmHandleEvent(dev->fd, &evctx); } - kms_bo_destroy(&bo); kms_bo_destroy(&other_bo); } @@ -1216,7 +1239,9 @@ int main(int argc, char **argv) struct plane_arg *plane_args = NULL; struct property_arg *prop_args = NULL; int ret; - + + memset(&dev, 0, sizeof dev); + opterr = 0; while ((c = getopt(argc, argv, optstr)) != -1) { switch (c) { @@ -1322,6 +1347,11 @@ int main(int argc, char **argv) return -1; } + if (test_vsync && !count) { + fprintf(stderr, "page flipping requires at least one -s option.\n"); + return -1; + } + dev.resources = get_resources(&dev); if (!dev.resources) { drmClose(dev.fd); @@ -1339,7 +1369,7 @@ int main(int argc, char **argv) for (i = 0; i < prop_count; ++i) set_property(&dev, &prop_args[i]); - if (count > 0) { + if (count || plane_count) { ret = kms_create(dev.fd, &dev.kms); if (ret) { fprintf(stderr, "failed to create kms driver: %s\n", @@ -1347,11 +1377,21 @@ int main(int argc, char **argv) return 1; } - set_mode(&dev, con_args, count, plane_args, plane_count, test_vsync); + if (count) + set_mode(&dev, con_args, count); + + if (plane_count) + set_planes(&dev, plane_args, plane_count); + + if (test_vsync) + test_page_flip(&dev, con_args, count); + if (drop_master) drmDropMaster(dev.fd); + kms_bo_destroy(&dev.mode.bo); kms_destroy(&dev.kms); + getchar(); }