From patchwork Tue Jan 7 08:55:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Abriou X-Patchwork-Id: 3446841 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 AE409C02DC for ; Tue, 7 Jan 2014 09:15:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 87E3D20103 for ; Tue, 7 Jan 2014 09:15:00 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 0A504200F0 for ; Tue, 7 Jan 2014 09:14:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 30754FBB0B; Tue, 7 Jan 2014 01:14:57 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 1104 seconds by postgrey-1.32 at gabe; Tue, 07 Jan 2014 01:14:48 PST Received: from eu1sys200aog111.obsmtp.com (eu1sys200aog111.obsmtp.com [207.126.144.131]) by gabe.freedesktop.org (Postfix) with ESMTP id 4BB39FBAEA for ; Tue, 7 Jan 2014 01:14:48 -0800 (PST) Received: from beta.dmz-eu.st.com ([164.129.1.35]) (using TLSv1) by eu1sys200aob111.postini.com ([207.126.147.11]) with SMTP ID DSNKUsvFhvFDKWf00Qy9SN75BEtaX2deit+1@postini.com; Tue, 07 Jan 2014 09:14:48 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 4504816F; Tue, 7 Jan 2014 08:55:23 +0000 (GMT) Received: from mail7.sgp.st.com (unknown [164.129.223.81]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 60A8AAF32; Tue, 7 Jan 2014 08:42:22 +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 BVG40648 (AUTH vincent.abriou@st.com); Tue, 7 Jan 2014 09:56:06 +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: Tue, 7 Jan 2014 09:55:40 +0100 Message-Id: <1389084940-14846-1-git-send-email-vincent.abriou@st.com> X-Mailer: git-send-email 1.7.9.5 Cc: 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.2 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 --- tests/modetest/modetest.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 51c4e6d..259d580 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 refresh_freq; 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 refresh_freq) { 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 (refresh_freq == 0) + /* If the refresh frequency is not specified then return the + * first mode that match with the name */ + return mode; + else if (mode->vrefresh == refresh_freq) + /* Else, return the mode that match the name and the specified + * refresh frequency */ + 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->refresh_freq); 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->refresh_freq = 0; pipe->crtc_id = (uint32_t)-1; strcpy(pipe->format_str, "XR24"); @@ -1226,11 +1237,22 @@ static int parse_connector(struct pipe_arg *pipe, const char *arg) arg = endp + 1; - p = strchrnul(arg, '@'); + /* Check if the refresh frequency is specified */ + p = strchr(arg, '-'); + if (p == NULL) + /* Else check if format is specified */ + p = strchrnul(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->refresh_freq = strtoul(p + 1, &endp, 10); + arg = endp; + /* Once done, check if format is specified */ + p = strchrnul(arg, '@'); + } + if (*p == '@') { strncpy(pipe->format_str, p + 1, 4); pipe->format_str[4] = '\0'; @@ -1323,7 +1345,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");