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: 167420 Delivered-To: patches@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1264783ilk; Fri, 21 Jun 2019 15:06:59 -0700 (PDT) X-Received: by 2002:a17:902:e011:: with SMTP id ca17mr67533643plb.328.1561154819866; Fri, 21 Jun 2019 15:06:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561154819; cv=none; d=google.com; s=arc-20160816; b=JYhHYrieFUM3PqpqcFl+LKgF2izzQS/LqFHIW3cvaiDQtupvs+dlnvwTQvsbMp2aEd X/bLS4pkTDz//8wUSBCESZdrC0fgkynQ/ox0L8tBq/l9Oza2DkGhmzpHtdJ9U8GXstR8 uQpiDihBZ+GNr6JmhQ/alELIqtj2jQBkaGXsTtZrMOXTac01V/D3YTv4zal98O4cY5Ng /pvTXlGSLmGDZopyqK5A1vSu6UgjWdfnMyBcoEgixGN/9Uay00jAzLPQF83ExJb4I0tI 4VKLE8CwtkEI7y7hNUVJdwQDNaS9FPOmvOJGcWVPf7dHXvqT1FQcZBhUXkbA6H+LpTzt tyyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=EmfJxIuxZw+Qe5gMw8AUa2eDjQtUWl8JbQLdvI2SeRM=; b=MM9ygJMFhYjJqDoYSpgbdg8eQEA9NAZREGaYuHJ12H/QXU+qsPeveh3u4BswEJpTqU C1WaVofIioO9r6dr5EQgSxJVg4G7FZCVOoZ4GJtMeiudlTH28byE7eE9VxBWpSZNARyj 8FmMXaC3xyvXkr6efNcHCizkkcLh7RDQw+nvtdUkoWeSAYuiznSaGWCj6PuprfxZh5jm OjwJscaPQdLFuwrcJuV5txzBL0zxAy0sMVWyyuo9RocHNDUhXGZYxjoIfImzB7z6ki0m tblrEmwyIK9KU4cEKyDhDZBnGni2MwtswqDG2odKyegXDIqDJjkuG8LKVJ1QdCwbNojo VJqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v60XcOqd; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id f17sor2615844pgv.83.2019.06.21.15.06.59 for (Google Transport Security); Fri, 21 Jun 2019 15:06:59 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v60XcOqd; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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-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=i+mCzszYR3pmHq+KagOES2sPM2bxUj4mPYGbD9pu381rBhuWH5kKXKvoixw1hBhuq8 bK/9ryYxIszMU1qr1PUz3ZX4rcRvdVNUUQwSgRTzspO8ks04K8j2SvpSjTO8Fh/YxpVK GxZHq+ItTTkhffkFgUMMF+g2pp1pC/SqdbGlx9ot6s4Rjvp7f+b7W4DzGPbfBkAs1Sns bx/XP+armK9mTtgtwTPqqkd+ENAChzUCG7y8/2wFpwiAdMfEFK659Wvio+Z9C9BmjWRm snnRyOkm2FEgp2WLV55jzTtPUk9yKSXgOwi0j4raLYbecm1SDNZPgbZ9OlC3WC8QDVgh +iTg== X-Gm-Message-State: APjAAAUEXe0lnaWvcCoTQb1PKzwqZTpvVu6VkU6nmsVfxfHP5ao+Dqsx iKYrXoCkbUKNhJ0NZtOX1bz43bud 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) Return-Path: 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 Cc: John Stultz , Ilia Mirkin , Rob Clark , Bjorn Andersson , Sumit Semwal 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 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 --- tests/modetest/modetest.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) -- 2.17.1 Reviewed-by: Ilia Mirkin 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");