From patchwork Fri Jun 21 22:06:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11010761 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D853F14BB for ; Fri, 21 Jun 2019 22:07:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C8B4F28B90 for ; Fri, 21 Jun 2019 22:07:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB47028B95; Fri, 21 Jun 2019 22:07:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6018328B90 for ; Fri, 21 Jun 2019 22:07:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5BD7E6E930; Fri, 21 Jun 2019 22:07:01 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by gabe.freedesktop.org (Postfix) with ESMTPS id 477F86E92F for ; Fri, 21 Jun 2019 22:07:00 +0000 (UTC) Received: by mail-pf1-x444.google.com with SMTP id 19so4260417pfa.4 for ; Fri, 21 Jun 2019 15:07:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=EmfJxIuxZw+Qe5gMw8AUa2eDjQtUWl8JbQLdvI2SeRM=; b=f5ebZF30dAkT0DR/AinThyMFfSbvrDXTqmPmIyig78b8+G+eCv56gHPvoLYK7qHYAI kNNt60/EHBi8EcWZL8Z74mm+merJroGHx82+NMJ4Ub7mgVa8u2Bgz0ysIxnxCQHtg7KF EcgakWbAA5QgKVwO8lwIlDA92v4s/f9Sajz1JEd0nLKoqg3eqF8qU6V7athPcryc6iqw cDdnYxxY6HQ5HRvpfFgX5/4YrunskreD7E8XUWHA9JaphbUs15IxuIYOY2dj1QQceLad wHFiesXtA4xfWlqWyNxJTPVWnJR4V9dqNLXja7Bbz0HPRl7MUN6JKijXjwgaa8IMdPFo R+ig== X-Gm-Message-State: APjAAAVfsnbvqoBJS/VKLz9ZKMqTr5IEB4X8xzLdmzYz3B7UMI2rsRJF 1JktqfmvZKWHKimjsjzFz0RgXklrHRs= X-Google-Smtp-Source: APXvYqwYmq3dhCHQogticsGtvYjcKhapfx6TjD59uIe9f2saSKMMM1AjeBZVqRXp4CmN+6QYfeFnFA== X-Received: by 2002:a63:7118:: with SMTP id m24mr5569352pgc.159.1561154819278; Fri, 21 Jun 2019 15:06:59 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id v10sm3563936pfe.163.2019.06.21.15.06.57 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 21 Jun 2019 15:06:58 -0700 (PDT) From: John Stultz To: dri-devel Subject: [RFC][PATCH] libdrm: modetest: Allow selecting modes by index Date: Fri, 21 Jun 2019 22:06:51 +0000 Message-Id: <20190621220651.62990-1-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=EmfJxIuxZw+Qe5gMw8AUa2eDjQtUWl8JbQLdvI2SeRM=; b=v60XcOqdtn2WYJM63RHZkBXcbutoxVAKaci/5HeVrBR0q70TK9Dg5BZP8a0+JRBKyX JWP7Ee5Re4RtEY+14k2HTVzVcwhMgz4uSr9bW7a/8dJRKSx0yFCzpemacBcqdcXhFQZo Pe0OUn13NdWR5m6SAbC3tkY6ZSClgeP9aFN3mRFQ1RLOwnSlExwDHDlqIsX/vyt5nyf2 uALBGcENsHHqrXU/2Vv5kJNLr5o3bWyaHQdWlqGa7klblDpW70B572tglaV8UbV2ohQS 4GbYvUKGKp9CftPQ74StsLublsyJKbUDA9DnvwjXUE44aYFkFxcP00aeKTRglFXGSBK2 SoSg== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rob Clark , Bjorn Andersson MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Often there are many similar modes, which cannot be selected via modetest due to its simple string matching. This change adds a mode index in the display output, which can then be used to specify a specific modeline to be set. Cc: Ilia Mirkin Cc: Rob Clark Cc: Bjorn Andersson Cc: Sumit Semwal Signed-off-by: John Stultz Reviewed-by: Ilia Mirkin --- tests/modetest/modetest.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 9c85c07b..4cab5013 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -204,9 +204,10 @@ static void dump_encoders(struct device *dev) printf("\n"); } -static void dump_mode(drmModeModeInfo *mode) +static void dump_mode(drmModeModeInfo *mode, int index) { - printf(" %s %d %d %d %d %d %d %d %d %d %d", + printf(" #%i %s %d %d %d %d %d %d %d %d %d %d", + index, mode->name, mode->vrefresh, mode->hdisplay, @@ -443,10 +444,10 @@ static void dump_connectors(struct device *dev) if (connector->count_modes) { printf(" modes:\n"); - printf("\tname refresh (Hz) hdisp hss hse htot vdisp " + printf("\tindex name refresh (Hz) hdisp hss hse htot vdisp " "vss vse vtot)\n"); for (j = 0; j < connector->count_modes; j++) - dump_mode(&connector->modes[j]); + dump_mode(&connector->modes[j], j); } if (_connector->props) { @@ -478,7 +479,7 @@ static void dump_crtcs(struct device *dev) crtc->buffer_id, crtc->x, crtc->y, crtc->width, crtc->height); - dump_mode(&crtc->mode); + dump_mode(&crtc->mode, 0); if (_crtc->props) { printf(" props:\n"); @@ -829,6 +830,16 @@ connector_find_mode(struct device *dev, uint32_t con_id, const char *mode_str, if (!connector || !connector->count_modes) return NULL; + /* Pick by Index */ + if (!strncmp(mode_str,"#",1)) { + int index = atoi(mode_str + 1); + + if (index >= connector->count_modes) + return NULL; + return &connector->modes[index]; + } + + /* Pick by Name */ for (i = 0; i < connector->count_modes; i++) { mode = &connector->modes[i]; if (!strcmp(mode->name, mode_str)) { @@ -1752,7 +1763,7 @@ static void usage(char *name) fprintf(stderr, "\n Test options:\n\n"); fprintf(stderr, "\t-P @:x[++][*][@]\tset a plane\n"); - fprintf(stderr, "\t-s [,][@]:[-][@]\tset a mode\n"); + fprintf(stderr, "\t-s [,][@]:[#][-][@]\tset a mode\n"); fprintf(stderr, "\t-C\ttest hw cursor\n"); fprintf(stderr, "\t-v\ttest vsynced page flipping\n"); fprintf(stderr, "\t-w ::\tset property\n");