From patchwork Fri Jun 14 21:21:28 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2724841 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 3DCACC0AB1 for ; Fri, 14 Jun 2013 21:35:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4F94D2034A for ; Fri, 14 Jun 2013 21:35:14 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 494B520319 for ; Fri, 14 Jun 2013 21:35:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 40D97E6083 for ; Fri, 14 Jun 2013 14:35:13 -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 0C3F1E5CE3 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 DCB2F35A4E; Fri, 14 Jun 2013 23:21:27 +0200 (CEST) From: Laurent Pinchart To: dri-devel@lists.freedesktop.org Subject: [PATCH v5 17/23] modetest: Give the CRTC ID to the -P option Date: Fri, 14 Jun 2013 23:21:28 +0200 Message-Id: <1371244894-27878-18-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 Planes are associated with CRTCs, not connectors. Don't try to be too clever, use the CRTC ID in the -P option. This prepares for splitting CRTC and planes setup. Signed-off-by: Laurent Pinchart --- tests/modetest/modetest.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index c46db59..0dfdaa5 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -652,7 +652,7 @@ struct connector_arg { }; struct plane_arg { - uint32_t con_id; /* the id of connector to bind to */ + uint32_t crtc_id; /* the id of CRTC to bind to */ bool has_position; int32_t x, y; uint32_t w, h; @@ -832,8 +832,7 @@ page_flip_handler(int fd, unsigned int frame, } } -static int -set_plane(struct device *dev, struct connector_arg *c, struct plane_arg *p) +static int set_plane(struct device *dev, struct plane_arg *p) { drmModePlane *ovr; uint32_t handles[4], pitches[4], offsets[4] = {0}; /* we only use [0] */ @@ -841,6 +840,7 @@ set_plane(struct device *dev, struct connector_arg *c, 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; unsigned int pipe; unsigned int i; @@ -848,14 +848,15 @@ set_plane(struct device *dev, struct connector_arg *c, struct plane_arg *p) * CRTC index first, then iterate over available planes. */ for (i = 0; i < (unsigned int)dev->resources->res->count_crtcs; i++) { - if (c->crtc_id == dev->resources->res->crtcs[i]) { + if (p->crtc_id == dev->resources->res->crtcs[i]) { + crtc = &dev->resources->crtcs[i]; pipe = i; break; } } - if (pipe == (unsigned int)dev->resources->res->count_crtcs) { - fprintf(stderr, "CRTC %u not found\n", c->crtc_id); + if (!crtc) { + fprintf(stderr, "CRTC %u not found\n", p->crtc_id); return -1; } @@ -869,7 +870,8 @@ set_plane(struct device *dev, struct connector_arg *c, struct plane_arg *p) } if (!plane_id) { - fprintf(stderr, "no unused plane available for CRTC %u\n", c->crtc_id); + fprintf(stderr, "no unused plane available for CRTC %u\n", + crtc->crtc->crtc_id); return -1; } @@ -890,8 +892,8 @@ set_plane(struct device *dev, struct connector_arg *c, struct plane_arg *p) if (!p->has_position) { /* Default to the middle of the screen */ - crtc_x = (c->crtc->mode->hdisplay - p->w) / 2; - crtc_y = (c->crtc->mode->vdisplay - p->h) / 2; + crtc_x = (crtc->mode->hdisplay - p->w) / 2; + crtc_y = (crtc->mode->vdisplay - p->h) / 2; } else { crtc_x = p->x; crtc_y = p->y; @@ -900,7 +902,7 @@ set_plane(struct device *dev, struct connector_arg *c, struct plane_arg *p) crtc_h = p->h; /* note src coords (last 4 args) are in Q16 format */ - if (drmModeSetPlane(dev->fd, plane_id, c->crtc_id, p->fb_id, + 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)) { fprintf(stderr, "failed to enable plane: %s\n", @@ -908,7 +910,7 @@ set_plane(struct device *dev, struct connector_arg *c, struct plane_arg *p) return -1; } - ovr->crtc_id = c->crtc_id; + ovr->crtc_id = crtc->crtc->crtc_id; return 0; } @@ -969,8 +971,8 @@ static void set_mode(struct device *dev, struct connector_arg *c, int count, /* if we have a plane/overlay to show, set that up now: */ for (j = 0; j < plane_count; j++) - if (p[j].con_id == c[i].id) - if (set_plane(dev, &c[i], &p[j])) + if (p[j].crtc_id == c[i].crtc_id) + if (set_plane(dev, &p[j])) return; } @@ -1099,7 +1101,7 @@ static int parse_plane(struct plane_arg *plane, const char *p) memset(plane, 0, sizeof *plane); - plane->con_id = strtoul(p, &end, 10); + plane->crtc_id = strtoul(p, &end, 10); if (*end != ':') return -EINVAL; @@ -1161,7 +1163,7 @@ static void usage(char *name) fprintf(stderr, "\t-p\tlist CRTCs and planes (pipes)\n"); fprintf(stderr, "\n Test options:\n\n"); - fprintf(stderr, "\t-P :x[++][@]\tset a plane\n"); + fprintf(stderr, "\t-P :x[++][@]\tset a plane\n"); fprintf(stderr, "\t-s [@]:[@]\tset a mode\n"); fprintf(stderr, "\t-v\ttest vsynced page flipping\n"); fprintf(stderr, "\t-w ::\tset property\n");