From patchwork Thu Jun 27 21:37:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 167995 Delivered-To: patches@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp2862120ilk; Thu, 27 Jun 2019 14:37:13 -0700 (PDT) X-Received: by 2002:a17:90a:a385:: with SMTP id x5mr8595132pjp.76.1561671433216; Thu, 27 Jun 2019 14:37:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561671433; cv=none; d=google.com; s=arc-20160816; b=ZT1H6Si7QcH4ItdhCCSAyWSNrlPc0PtAOq5bEp14d1cjhZQ99NPZk/rKI7I7L7cWmF 79MjXcX69WZrSPAZumvTzv8a5QZp0Ej5nm3DP/bfiMxQGf49o3kHvWBMEu1LOdvgwoI6 WXTzhQIWS2x6Q+rx5hVajtjOKTq9e+94PdZPgf1sc5LfLr2ZGvTyq7BfxU5sOYaXk9+5 kn5YTXghfWrDbXzYAbzkh/OcRR/E5f7dhYMlZ4Cy2+f9SS4WGegOy6hBUN5IWJFRXO5G rIEOri1zLliLEIHgAWvC/ULXlLgXRDVntq93JCzJ7ogntv/cZY9BRe8sbsyddrtCjqDB XXEQ== 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=lnYGFx8CYsH6vPjtWwJaAsoQv2lSpTxEyZZY8jL5vW4=; b=XmSmseUXBVuuwrJK3iQ80IeRNjRhMg6XfBS1zP9LEvBWc5/vxUnzG18Zd2m6PBPQ5k eFudgyue10UT8y4wMwQxXftJ65f2f0V9NkWAdzi9pRS7bCsdgy8TkQFvApeIneaXHlMU 09OFQqSrhftyMuIo5hhZXr+Ecec6TREFeZhGYkUZH2WxYbSyxKOtHze3La24HPp/yFqO lBQ/cKm2x24NBnbGMI7EJeaUfIFdLF1DzMTvO2Guaoj5T9O8rzE4NoM9uiM6jm/iWZKQ XMeiuhZSJ7L2jHd5ntvj5uyfvmijB3ASSAp6FrLnetG9W6xZY0UE6K8WIRr5vClsqOJ+ GA4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qV7s6bLT; 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 y16sor57491pfe.48.2019.06.27.14.37.13 for (Google Transport Security); Thu, 27 Jun 2019 14:37:13 -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=qV7s6bLT; 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=lnYGFx8CYsH6vPjtWwJaAsoQv2lSpTxEyZZY8jL5vW4=; b=qV7s6bLTLwTMcfMAeuufxfY9ClWV5jsO+sI8rRv/8h/LCMIaQJaTtcKgONtxUrMHXq wAOWhYb/9icet5V6Azfcc7IrWzquCuHDCmuDTO0ND/EL7uD55fRZyhsUiunQzE3wqViK SQYQOvUCqx8eKSHn4r+O+a4zPi5+tWu3zPpB6Tq6mFVtdDWOsABFbX6lNkv6rk3Ve/U4 5Qx/WWeCKirAFfSHcpUxNNB9+WFdOmjv9EKL5F1kDV1FztpbfhhIzsvhD9TcYbf7qJ+T 3vkKLTUZt8X4VkFfJuiJhGS+7HGIGUG2H8cjbMj5V+QKudRULmU10Q77XZtWui6+WfeE eufA== 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=lnYGFx8CYsH6vPjtWwJaAsoQv2lSpTxEyZZY8jL5vW4=; b=AdrQze78eUKGUcAKSVnZa6njhb04QM8Pfu8XkGSERTIMBTSS0CvdHaI4KUrEvKvGBo GTWKwJj46wS8tF6ArlX/v2+oTrO38zaQLNfFGIyDR2wxwlFEIaswvdPt+MdbUbOhKF17 n9iii93B0Xzv/mcM0At37VPw2/cRijQ8fGxOJ4qOCnUujYo/LgeJEdxYDBkjQZoc5sW5 mGjWzUGrTKCjZu/Dz7Euhd1YNuGl8EkBJUHIq3+TRGxsRATN5c6/d5cKKOQHmuEhe1ke cSMOmRQVeidVZYkH1ZBQGOK4famk5ns4I/9Gb+t5F/SPJIJKb8WpI7Sz2pTf2MRiWKF+ lesg== X-Gm-Message-State: APjAAAUUwqlVtX3CHWXbyGLHkiExhfGx/lRaYZgnaxv5lBNlQ73450Ya c6sDIVeIzclosKKWtqHPwz0JkEAr X-Google-Smtp-Source: APXvYqzY9KfA/DPuUq0A6665WMnGE5zQtZi5aTJobFd/CJsCQRAK+MKmlKJympq0hV3h0DoStErXsA== X-Received: by 2002:a65:50cb:: with SMTP id s11mr5778345pgp.371.1561671432655; Thu, 27 Jun 2019 14:37:12 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id a4sm56288pff.9.2019.06.27.14.37.11 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 27 Jun 2019 14:37:11 -0700 (PDT) From: John Stultz To: dri-devel Cc: John Stultz , Ilia Mirkin , Rob Clark , Bjorn Andersson , Sumit Semwal Subject: [PATCH v3] libdrm: modetest: Allow selecting modes by index Date: Thu, 27 Jun 2019 21:37:07 +0000 Message-Id: <20190627213707.46094-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 Reviewed-by: Ilia Mirkin Signed-off-by: John Stultz --- v2: Reworked mode_str check per Ilia's suggestion v3: Added index < 0 check per Ilia's suggestion --- tests/modetest/modetest.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) -- 2.17.1 diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 9c85c07b..5e1b623a 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 || index < 0) + 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");