From patchwork Fri Jul 8 18:21:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 12911661 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 434C3CCA47B for ; Fri, 8 Jul 2022 18:22:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 048C210EBDE; Fri, 8 Jul 2022 18:22:01 +0000 (UTC) Received: from laurent.telenet-ops.be (laurent.telenet-ops.be [IPv6:2a02:1800:110:4::f00:19]) by gabe.freedesktop.org (Postfix) with ESMTPS id 26F2610EBE1 for ; Fri, 8 Jul 2022 18:21:54 +0000 (UTC) Received: from ramsan.of.borg ([84.195.186.194]) by laurent.telenet-ops.be with bizsmtp id siMt2700F4C55Sk01iMtsX; Fri, 08 Jul 2022 20:21:53 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1o9sbx-002fNi-4p; Fri, 08 Jul 2022 20:21:53 +0200 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1o9sbw-00BtVS-5Q; Fri, 08 Jul 2022 20:21:52 +0200 From: Geert Uytterhoeven To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm v2 06/10] modetest: Add support for parsing big-endian formats Date: Fri, 8 Jul 2022 20:21:45 +0200 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Geert Uytterhoeven Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" When specifying a frame buffer format like "RG16be" (big-endian RG16), modetest still uses the little-endian variant, as the format string is truncated to four characters. Fix this by increasing the format string size to 7 bytes (6 characters + NUL terminator). Signed-off-by: Geert Uytterhoeven --- v2: - New. --- tests/modetest/modetest.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index f70043d1e6815497..7c6c21ef5174c41a 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -821,7 +821,7 @@ struct pipe_arg { unsigned int num_cons; uint32_t crtc_id; char mode_str[64]; - char format_str[5]; + char format_str[7]; float vrefresh; unsigned int fourcc; drmModeModeInfo *mode; @@ -843,7 +843,7 @@ struct plane_arg { unsigned int old_fb_id; struct bo *bo; struct bo *old_bo; - char format_str[5]; /* need to leave room for terminating \0 */ + char format_str[7]; /* need to leave room for "be" and terminating \0 */ unsigned int fourcc; }; @@ -1917,8 +1917,8 @@ static int parse_connector(struct pipe_arg *pipe, const char *arg) } if (*p == '@') { - strncpy(pipe->format_str, p + 1, 4); - pipe->format_str[4] = '\0'; + strncpy(pipe->format_str, p + 1, 6); + pipe->format_str[6] = '\0'; } pipe->fourcc = util_format_fourcc(pipe->format_str); @@ -1970,8 +1970,8 @@ static int parse_plane(struct plane_arg *plane, const char *p) } if (*end == '@') { - strncpy(plane->format_str, end + 1, 4); - plane->format_str[4] = '\0'; + strncpy(plane->format_str, end + 1, 6); + plane->format_str[6] = '\0'; } else { strcpy(plane->format_str, "XR24"); }