From patchwork Fri Jun 14 21:34:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 2725101 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 BB064C0AB1 for ; Fri, 14 Jun 2013 21:55:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CC8C32024F for ; Fri, 14 Jun 2013 21:55:45 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id D72042024E for ; Fri, 14 Jun 2013 21:55:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E6298E6109 for ; Fri, 14 Jun 2013 14:55:44 -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 384B2E5EF1 for ; Fri, 14 Jun 2013 14:35:19 -0700 (PDT) Received: from avalon.ideasonboard.com (unknown [91.177.128.27]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8F7D035A6F; Fri, 14 Jun 2013 23:35:09 +0200 (CEST) From: Laurent Pinchart To: dri-devel@lists.freedesktop.org Subject: [PATCH v6 15/23] modetest: Store the crtc in the connector_arg structure Date: Fri, 14 Jun 2013 23:34:49 +0200 Message-Id: <1371245697-29504-16-git-send-email-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 1.8.1.5 In-Reply-To: <1371245697-29504-1-git-send-email-laurent.pinchart@ideasonboard.com> References: <1371245697-29504-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 This prepares the code for the split in separate functions of CRTC and planes setup. Signed-off-by: Laurent Pinchart --- tests/modetest/modetest.c | 58 ++++++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 2c3e093..6fbaf09 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -634,11 +634,12 @@ error: */ struct connector_arg { uint32_t id; + uint32_t crtc_id; char mode_str[64]; char format_str[5]; unsigned int fourcc; drmModeModeInfo *mode; - int crtc; + struct crtc *crtc; unsigned int fb_id[2], current_fb_id; struct timeval start; @@ -690,18 +691,33 @@ static void connector_find_mode(struct device *dev, struct connector_arg *c) return; } - /* Now get the encoder */ - for (i = 0; i < dev->resources->res->count_encoders; i++) { - encoder = dev->resources->encoders[i].encoder; - if (!encoder) - continue; + /* If the CRTC ID was specified, get the corresponding CRTC. Otherwise + * locate a CRTC that can be attached to the connector. + */ + if (c->crtc_id == (uint32_t)-1) { + for (i = 0; i < dev->resources->res->count_encoders; i++) { + encoder = dev->resources->encoders[i].encoder; + if (!encoder) + continue; + + if (encoder->encoder_id == connector->encoder_id) { + c->crtc_id = encoder->crtc_id; + break; + } + } + } + + if (c->crtc_id == (uint32_t)-1) + return; - if (encoder->encoder_id == connector->encoder_id) + for (i = 0; i < dev->resources->res->count_crtcs; i++) { + struct crtc *crtc = &dev->resources->crtcs[i]; + + if (c->crtc_id == crtc->crtc->crtc_id) { + c->crtc = crtc; break; + } } - - if (c->crtc == -1) - c->crtc = encoder->crtc_id; } /* ----------------------------------------------------------------------------- @@ -796,7 +812,7 @@ page_flip_handler(int fd, unsigned int frame, else new_fb_id = c->fb_id[0]; - drmModePageFlip(fd, c->crtc, new_fb_id, + drmModePageFlip(fd, c->crtc_id, new_fb_id, DRM_MODE_PAGE_FLIP_EVENT, c); c->current_fb_id = new_fb_id; c->swap_count++; @@ -826,14 +842,14 @@ 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 == (int)dev->resources->res->crtcs[i]) { + if (c->crtc_id == dev->resources->res->crtcs[i]) { pipe = i; break; } } if (pipe == (unsigned int)dev->resources->res->count_crtcs) { - fprintf(stderr, "CRTC %u not found\n", c->crtc); + fprintf(stderr, "CRTC %u not found\n", c->crtc_id); return -1; } @@ -847,7 +863,7 @@ 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); + fprintf(stderr, "no unused plane available for CRTC %u\n", c->crtc_id); return -1; } @@ -878,7 +894,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, p->fb_id, + if (drmModeSetPlane(dev->fd, plane_id, c->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", @@ -886,7 +902,7 @@ set_plane(struct device *dev, struct connector_arg *c, struct plane_arg *p) return -1; } - ovr->crtc_id = c->crtc; + ovr->crtc_id = c->crtc_id; return 0; } @@ -930,9 +946,9 @@ static void set_mode(struct device *dev, struct connector_arg *c, int count, continue; printf("setting mode %s@%s on connector %d, crtc %d\n", - c[i].mode_str, c[i].format_str, c[i].id, c[i].crtc); + c[i].mode_str, c[i].format_str, c[i].id, c[i].crtc_id); - ret = drmModeSetCrtc(dev->fd, c[i].crtc, fb_id, x, 0, + ret = drmModeSetCrtc(dev->fd, c[i].crtc_id, fb_id, x, 0, &c[i].id, 1, c[i].mode); /* XXX: Actually check if this is needed */ @@ -971,7 +987,7 @@ static void set_mode(struct device *dev, struct connector_arg *c, int count, if (c[i].mode == NULL) continue; - ret = drmModePageFlip(dev->fd, c[i].crtc, other_fb_id, + ret = drmModePageFlip(dev->fd, c[i].crtc_id, other_fb_id, DRM_MODE_PAGE_FLIP_EVENT, &c[i]); if (ret) { fprintf(stderr, "failed to page flip: %s\n", strerror(errno)); @@ -1039,13 +1055,13 @@ static int parse_connector(struct connector_arg *c, const char *arg) const char *p; char *endp; - c->crtc = -1; + c->crtc_id = (uint32_t)-1; strcpy(c->format_str, "XR24"); c->id = strtoul(arg, &endp, 10); if (*endp == '@') { arg = endp + 1; - c->crtc = strtoul(arg, &endp, 10); + c->crtc_id = strtoul(arg, &endp, 10); } if (*endp != ':') return -1;