From patchwork Fri Jul 20 12:50:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 1220981 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 24E373FC33 for ; Fri, 20 Jul 2012 12:58:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 050579EBB9 for ; Fri, 20 Jul 2012 05:58:51 -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 2A03D9ED73 for ; Fri, 20 Jul 2012 05:50:49 -0700 (PDT) Received: from avalon.ideasonboard.com (unknown [91.178.183.173]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CE03835A8D for ; Fri, 20 Jul 2012 14:50:44 +0200 (CEST) From: Laurent Pinchart To: dri-devel@lists.freedesktop.org Subject: [PATCH 7/7] modetest: Make frame buffer format configurable on the command line Date: Fri, 20 Jul 2012 14:50:48 +0200 Message-Id: <1342788648-28528-9-git-send-email-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 1.7.8.6 In-Reply-To: <1342788648-28528-1-git-send-email-laurent.pinchart@ideasonboard.com> References: <1342788648-28528-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 Signed-off-by: Laurent Pinchart --- tests/modetest/modetest.c | 60 +++++++++++++++++++++++++++++++++------------ 1 files changed, 44 insertions(+), 16 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 3e0af17..3ed39b7 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -488,6 +488,8 @@ static void dump_planes(void) struct connector { uint32_t id; char mode_str[64]; + char format_str[5]; + unsigned int fourcc; drmModeModeInfo *mode; drmModeEncoder *encoder; int crtc; @@ -1696,12 +1698,13 @@ set_mode(struct connector *c, int count, struct plane *p, int plane_count, return; } - bo = create_test_buffer(kms, DRM_FORMAT_XRGB8888, width, height, handles, + bo = create_test_buffer(kms, c->fourcc, width, height, handles, pitches, offsets, PATTERN_SMPTE); if (bo == NULL) return; - ret = drmModeAddFB(fd, width, height, 24, 32, pitches[0], handles[0], &fb_id); + ret = drmModeAddFB2(fd, width, 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)); @@ -1713,8 +1716,8 @@ set_mode(struct connector *c, int count, struct plane *p, int plane_count, if (c[i].mode == NULL) continue; - printf("setting mode %s on connector %d, crtc %d\n", - c[i].mode_str, c[i].id, c[i].crtc); + 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); ret = drmModeSetCrtc(fd, c[i].crtc, fb_id, x, 0, &c[i].id, 1, c[i].mode); @@ -1739,13 +1742,13 @@ set_mode(struct connector *c, int count, struct plane *p, int plane_count, if (!page_flip) return; - other_bo = create_test_buffer(kms, DRM_FORMAT_XRGB8888, width, height, handles, + other_bo = create_test_buffer(kms, c->fourcc, width, height, handles, pitches, offsets, PATTERN_PLAIN); if (other_bo == NULL) return; - ret = drmModeAddFB(fd, width, height, 32, 32, pitches[0], handles[0], - &other_fb_id); + ret = drmModeAddFB2(fd, width, height, c->fourcc, handles, pitches, offsets, + &other_fb_id, 0); if (ret) { fprintf(stderr, "failed to add fb: %s\n", strerror(errno)); return; @@ -1820,17 +1823,44 @@ extern char *optarg; extern int optind, opterr, optopt; static char optstr[] = "ecpmfs:P:v"; +#define min(a, b) ((a) < (b) ? (a) : (b)) + static int parse_connector(struct connector *c, const char *arg) { + unsigned int len; + const char *p; + char *endp; + c->crtc = -1; + strcpy(c->format_str, "XR24"); - if (sscanf(arg, "%d:%64s", &c->id, &c->mode_str) == 2) - return 0; + c->id = strtoul(arg, &endp, 10); + if (*endp == '@') { + arg = endp + 1; + c->crtc = strtoul(arg, &endp, 10); + } + if (*endp != ':') + return -1; - if (sscanf(arg, "%d@%d:%64s", &c->id, &c->crtc, &c->mode_str) == 3) - return 0; + arg = endp + 1; - return -1; + p = strchrnul(arg, '@'); + len = min(sizeof c->mode_str - 1, p - arg); + strncpy(c->mode_str, arg, len); + c->mode_str[len] = '\0'; + + if (*p == '@') { + strncpy(c->format_str, p + 1, 4); + c->format_str[4] = '\0'; + + c->fourcc = format_fourcc(p + 1); + if (c->fourcc == 0) { + fprintf(stderr, "unknown format %s\n", c->format_str); + return -1; + } + } + + return 0; } static int parse_plane(struct plane *p, const char *arg) @@ -1859,10 +1889,8 @@ void usage(char *name) fprintf(stderr, "\t-m\tlist modes\n"); fprintf(stderr, "\t-f\tlist framebuffers\n"); fprintf(stderr, "\t-v\ttest vsynced page flipping\n"); - fprintf(stderr, "\t-s :\tset a mode\n"); - fprintf(stderr, "\t-s @:\tset a mode\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-P :x[@]\tset a plane\n"); fprintf(stderr, "\n\tDefault is to dump all info.\n"); exit(0); }