From patchwork Fri Jan 10 10:02:33 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Abriou X-Patchwork-Id: 3465451 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8105CC02DC for ; Fri, 10 Jan 2014 10:02:55 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 43E252010E for ; Fri, 10 Jan 2014 10:02:54 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id AE0C5200E7 for ; Fri, 10 Jan 2014 10:02:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 14911FB7CC; Fri, 10 Jan 2014 02:02:49 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from eu1sys200aog114.obsmtp.com (eu1sys200aog114.obsmtp.com [207.126.144.137]) by gabe.freedesktop.org (Postfix) with ESMTP id 73D43FB7CC for ; Fri, 10 Jan 2014 02:02:46 -0800 (PST) Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob114.postini.com ([207.126.147.11]) with SMTP ID DSNKUs/FQ5tu0c2bCzl7mYVhs8Rpb6pP3kcH@postini.com; Fri, 10 Jan 2014 10:02:46 UTC Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 3222811E; Fri, 10 Jan 2014 10:01:56 +0000 (GMT) Received: from mail7.sgp.st.com (unknown [164.129.223.81]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id D51F115C97; Fri, 10 Jan 2014 09:48:55 +0000 (GMT) Received: from lmenx30g.lme.st.com (lmenx30g.lme.st.com [10.201.23.35]) by mail7.sgp.st.com (MOS 4.3.3-GA) with ESMTP id BVN24017 (AUTH vincent.abriou@st.com); Fri, 10 Jan 2014 11:02:39 +0100 From: Vincent ABRIOU To: dri-devel@lists.freedesktop.org Subject: [PATCH] modetest: add the possibility to select the refresh frequency for a mode Date: Fri, 10 Jan 2014 11:02:33 +0100 Message-Id: <1389348153-32086-1-git-send-email-vincent.abriou@st.com> X-Mailer: git-send-email 1.7.9.5 Cc: laurent.pinchart@ideasonboard.com, Benjamin Gaignard 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@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When mode is selected we only give the name of the mode as parameter. But sometime, two different modes have the same name but not the same vrefresh frequency. This patch give the possibility to select a mode by its name and optionally by its refresh frequency. Signed-off-by: Vincent Abriou Acked-by: Laurent Pinchart --- tests/modetest/modetest.c | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 51c4e6d..bc9c998 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -693,6 +693,7 @@ struct pipe_arg { uint32_t crtc_id; char mode_str[64]; char format_str[5]; + unsigned int vrefresh; unsigned int fourcc; drmModeModeInfo *mode; struct crtc *crtc; @@ -714,7 +715,8 @@ struct plane_arg { }; static drmModeModeInfo * -connector_find_mode(struct device *dev, uint32_t con_id, const char *mode_str) +connector_find_mode(struct device *dev, uint32_t con_id, const char *mode_str, + const unsigned int vrefresh) { drmModeConnector *connector; drmModeModeInfo *mode; @@ -726,8 +728,16 @@ connector_find_mode(struct device *dev, uint32_t con_id, const char *mode_str) for (i = 0; i < connector->count_modes; i++) { mode = &connector->modes[i]; - if (!strcmp(mode->name, mode_str)) - return mode; + if (!strcmp(mode->name, mode_str)) { + /* If the vertical refresh frequency is not specified then return the + * first mode that match with the name. Else, return the mode that match + * the name and the specified vertical refresh frequency. + */ + if (vrefresh == 0) + return mode; + else if (mode->vrefresh == vrefresh) + return mode; + } } return NULL; @@ -789,7 +799,7 @@ static int pipe_find_crtc_and_mode(struct device *dev, struct pipe_arg *pipe) for (i = 0; i < (int)pipe->num_cons; i++) { mode = connector_find_mode(dev, pipe->con_ids[i], - pipe->mode_str); + pipe->mode_str, pipe->vrefresh); if (mode == NULL) { fprintf(stderr, "failed to find mode \"%s\" for connector %u\n", @@ -1059,8 +1069,8 @@ static void set_mode(struct device *dev, struct pipe_arg *pipes, unsigned int co if (pipe->mode == NULL) continue; - printf("setting mode %s@%s on connectors ", - pipe->mode_str, pipe->format_str); + printf("setting mode %s-%dHz@%s on connectors ", + pipe->mode_str, pipe->mode->vrefresh, pipe->format_str); for (j = 0; j < pipe->num_cons; ++j) printf("%u, ", pipe->con_ids[j]); printf("crtc %d\n", pipe->crtc->crtc->crtc_id); @@ -1192,6 +1202,7 @@ static int parse_connector(struct pipe_arg *pipe, const char *arg) const char *p; char *endp; + pipe->vrefresh = 0; pipe->crtc_id = (uint32_t)-1; strcpy(pipe->format_str, "XR24"); @@ -1226,11 +1237,19 @@ static int parse_connector(struct pipe_arg *pipe, const char *arg) arg = endp + 1; - p = strchrnul(arg, '@'); + /* Search for the vertical refresh or the format. */ + p = strpbrk(arg, "-@"); + if (p == NULL) + p = arg + strlen(arg); len = min(sizeof pipe->mode_str - 1, (unsigned int)(p - arg)); strncpy(pipe->mode_str, arg, len); pipe->mode_str[len] = '\0'; + if (*p == '-') { + pipe->vrefresh = strtoul(p + 1, &endp, 10); + p = endp; + } + if (*p == '@') { strncpy(pipe->format_str, p + 1, 4); pipe->format_str[4] = '\0'; @@ -1323,7 +1342,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-v\ttest vsynced page flipping\n"); fprintf(stderr, "\t-w ::\tset property\n");