From patchwork Mon Jun 24 20:27:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 167649 Delivered-To: patches@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp4658689ilk; Mon, 24 Jun 2019 13:27:41 -0700 (PDT) X-Received: by 2002:a63:1365:: with SMTP id 37mr7070002pgt.266.1561408061556; Mon, 24 Jun 2019 13:27:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561408061; cv=none; d=google.com; s=arc-20160816; b=ivMq0kZuvUy3SFAX+lWR8B81oWMRKDtOZ2+9f9edNCZFs8HCgzBgQAHHAde0+f2sOV GAGGlonm+6JOmOEjQxWkUGBwBp5Z53pdecVt03jOvQ3/8Re2wo1IyAso3BK5EZnWYYhZ aDCACFqPWbadGXbUOHPzteUT1l0MJGW8wyLAuBeSsLbe7dEjGVjKgaIVivRxn+Bhr/kd stBJKcD++an2bPHq+CbG5xF3MXkyj8ECsN+c6KmNmitZtrl4wy4CJKBMwfgRQiDratwb o3LNwthvtBZG2QwEFXjuZ5I8Os6LVSWtq5juAwHB3sSZOoJyOR7iqQqgZBQA27qUhL+I XDkQ== 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=Xm3E2aGr5dZvLkpn1QbXOhXQmIbRzV9KHBP8zZjQp7Y=; b=OyqKpRK4UWxb/KvAqcEAKeBr+k4Rtjz0+f9U2dKdbTze6PXNngLXfKcwp6yJDYmYoZ fhz0lR1jMoZG51U2FEKQyULesmuu4UbAV5OggUFqGg8VVUqAfK+ZWcg6rajqqkTTmigp tAEcuxFN2Wz+DIp4RJucjJnzJgStTLMO9Sw1989sWeXLiA6Sx2YVNbU+MeVZxn1GUbAP vdzdzepHf2LIhzuBox4MXq7XbsIHIVaJCI8c+J4lVD47GdLOFmhH9Ku3dscyZ4qzi2Iq FKPviWE2DRhoA31eZpC7+gkle2ogWRS0hzpuO/Mvh+X7EDaEdOIYwRgpZ/olxJcust2C FFLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hVIJS0MK; 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 e127sor5916582pgc.7.2019.06.24.13.27.41 for (Google Transport Security); Mon, 24 Jun 2019 13:27:41 -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=hVIJS0MK; 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=Xm3E2aGr5dZvLkpn1QbXOhXQmIbRzV9KHBP8zZjQp7Y=; b=hVIJS0MK27V9qFYbti2Qc+HlVtqB9uaniCdnm5dMUAtDQP+o+v/SSmz0KeLVIyArq/ E97JrMzLhsq+lcR40Bm79qD/yfUGYLtTcDgUl5aq1TO12UmzFeYnaP23IAKe2YC2w+hX HaFD5ZQMrv1C6tA+bv3dx9WtYmsvCcAxbPxCHWXbVinwOoxuggNxUCsFnQs2Kn+zJ6W9 c8gbNc/oSCrd6H9ArHhF+UYt9q0gk9QgdYAFGsdph68p0nhSeidNG9wK8jMpz12bL2+C Zsl+vj2o3kurawIvRntaP9prlcJm7PV4d/+4/WtgjN1kPl/v7AqdK9i0z8tpIGPcc9QY COPw== 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=Xm3E2aGr5dZvLkpn1QbXOhXQmIbRzV9KHBP8zZjQp7Y=; b=a4+X+0ZEiG48owKnm4Ln9fTi9GyszYMAncaSDZDQE6Ys3S77PodWz2suqX8feNn+by 6vjuxskuAhSP5PVpTzTb0G5mwXsZaCEOOVZ7k/7sKg47Qlz4pXmaddxlnKlcOEwx9WFV eqD3o2rGI1cyNwse02yfmvp612kgK2V3dujNy8UEJDYCLyes826CBQTjknDyn9q3L9bW iUSoVfRsSNRS+XkrVCZZ9LS7MPSuysbGix9Y7B2Qwto4ffS2TfSLpvQPl2W50EV2cpiP ffag3nBCElda58J8v0NtPEOUgL4v0rW4uTnvdgSx3ceCj5zasbnfdYX+2aajNNnDw9eB hh/w== X-Gm-Message-State: APjAAAVv+W7Ox5a/mBtmXx5U1uQ1O8I9CKTCCubRctXYum0aDf7IK3IH ccnIbTDlSYEyMg/20s5xJHiHgzHi X-Google-Smtp-Source: APXvYqwTdunXVLHzE98ld4jY9SPbBpG1RfzwPwbc0dz5O1z2DA5FG4FNhdVPjdxui0JexmKV10pU6g== X-Received: by 2002:a63:4e58:: with SMTP id o24mr6317258pgl.366.1561408060852; Mon, 24 Jun 2019 13:27:40 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id y12sm11466778pgi.10.2019.06.24.13.27.39 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 24 Jun 2019 13:27:40 -0700 (PDT) From: John Stultz To: dri-devel Cc: John Stultz , Ilia Mirkin , Rob Clark , Bjorn Andersson , Sumit Semwal Subject: [PATCH v2] libdrm: modetest: Allow selecting modes by index Date: Mon, 24 Jun 2019 20:27:35 +0000 Message-Id: <20190624202735.125139-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 --- v2: Reworked mode_str check per Ilia's suggestion --- 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..5a04190c 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 (mode_str[0] == '#') { + 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");