From patchwork Fri Jul 8 18:21:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 12911659 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 37EE1C43334 for ; Fri, 8 Jul 2022 18:22:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 438B910EBF4; Fri, 8 Jul 2022 18:22:01 +0000 (UTC) Received: from albert.telenet-ops.be (albert.telenet-ops.be [IPv6:2a02:1800:110:4::f00:1a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3C12E10EBD9 for ; Fri, 8 Jul 2022 18:21:53 +0000 (UTC) Received: from ramsan.of.borg ([84.195.186.194]) by albert.telenet-ops.be with bizsmtp id siMs2700E4C55Sk06iMscQ; Fri, 08 Jul 2022 20:21:52 +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 1o9sbw-002fNd-Eb; Fri, 08 Jul 2022 20:21:52 +0200 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1o9sbw-00BtUt-1r; Fri, 08 Jul 2022 20:21:52 +0200 From: Geert Uytterhoeven To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm v2 01/10] intel: Improve checks for big-endian Date: Fri, 8 Jul 2022 20:21:40 +0200 Message-Id: <289528263127053c7d683a582f77927e7acd4d8c.1657302103.git.geert@linux-m68k.org> 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" - sparc64-linux-gnu-gcc does not define __BIG_ENDIAN__ or SPARC, but does define __sparc__, hence replace the check for SPARC by a check for __sparc__, - powerpc{,64,64}-linux-gnu-gcc does not define __ppc__ or __ppc64__, but does define __BIG_ENDIAN__. powerpc64le-linux-gnu-gcc does not define __ppc__ or __ppc64__, but does define __LITTLE_ENDIAN__. Hence remove the checks for __ppc__ and __ppc64__. - arm-linux-gnueabi-gcc and aarch64-linux-gnu-gcc do not define __BIG_ENDIAN__ for targets in big-endian mode, but do define __ARM_BIG_ENDIAN, so add a check for the latter, - m68k-linux-gnu-gcc does not define __BIG_ENDIAN__, but does define __mc68000__, so add a check for the latter, - mips{,64}-linux-gnu{,abi64}-gcc does not define __BIG_ENDIAN__, but does define __MIPSEB__, so add a check for the latter, - s390x-linux-gnu-gcc does not define __BIG_ENDIAN__, but does define __s390__, so add a check for the latter, - hppa{,64}-linux-gnu-gcc, microblaze-linux-gcc, and sh4-linux-gnu-gcc in big-endian mode do define __BIG_ENDIAN__, and thus should work out-of-the-box. Signed-off-by: Geert Uytterhoeven --- Untested due to lack of hardware. v2: - Add arm, aarch64, microblaze, s390, and sh. --- intel/uthash.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intel/uthash.h b/intel/uthash.h index 45d1f9fc12a1d6f9..a8465f23ff9fbcac 100644 --- a/intel/uthash.h +++ b/intel/uthash.h @@ -648,7 +648,7 @@ do { #define MUR_PLUS2_ALIGNED(p) (((unsigned long)p & 3UL) == 2UL) #define MUR_PLUS3_ALIGNED(p) (((unsigned long)p & 3UL) == 3UL) #define WP(p) ((uint32_t*)((unsigned long)(p) & ~3UL)) -#if (defined(__BIG_ENDIAN__) || defined(SPARC) || defined(__ppc__) || defined(__ppc64__)) +#if (defined(__BIG_ENDIAN__) || defined(__ARM_BIG_ENDIAN) || defined(__mc68000__) || defined(__MIPSEB__) || defined(__s390__) || defined(__sparc__)) #define MUR_THREE_ONE(p) ((((*WP(p))&0x00ffffff) << 8) | (((*(WP(p)+1))&0xff000000) >> 24)) #define MUR_TWO_TWO(p) ((((*WP(p))&0x0000ffff) <<16) | (((*(WP(p)+1))&0xffff0000) >> 16)) #define MUR_ONE_THREE(p) ((((*WP(p))&0x000000ff) <<24) | (((*(WP(p)+1))&0xffffff00) >> 8)) From patchwork Fri Jul 8 18:21:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 12911665 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 4D0E9CCA47F for ; Fri, 8 Jul 2022 18:22:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 63B6810EC23; Fri, 8 Jul 2022 18:22:04 +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 B454B10EBE5 for ; Fri, 8 Jul 2022 18:21:53 +0000 (UTC) Received: from ramsan.of.borg ([84.195.186.194]) by laurent.telenet-ops.be with bizsmtp id siMt270094C55Sk01iMtsT; 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 1o9sbw-002fNe-Sq; Fri, 08 Jul 2022 20:21:52 +0200 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1o9sbw-00BtV0-2V; Fri, 08 Jul 2022 20:21:52 +0200 From: Geert Uytterhoeven To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm v2 02/10] util: Fix 32 bpp patterns on big-endian Date: Fri, 8 Jul 2022 20:21:41 +0200 Message-Id: <03051645f43b463e73c4426b95f8a70008f89793.1657302103.git.geert@linux-m68k.org> 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: Pekka Paalanen , Geert Uytterhoeven Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" DRM formats are defined to be little-endian, unless the DRM_FORMAT_BIG_ENDIAN flag is set. Hence writes of multi-byte pixel values need to take endianness into account. Introduce a swap32() helper to byteswap 32-bit values, and a cpu_to_le32() helper to convert 32-bit values from CPU-endian to little-endian, and use the latter in the various pattern fill functions for 32-bit formats. Signed-off-by: Geert Uytterhoeven Acked-by: Pekka Paalanen --- Works now with Linux' drm_fb_xrgb8888_to_rgb332_line(), which uses le32_to_cpu() to read pixel values from memory. v2: - Add Acked-by, - Add swap32() intermediate helper, - Add __ARM_BIG_ENDIAN and __s390__. --- tests/util/pattern.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/tests/util/pattern.c b/tests/util/pattern.c index 631114563fa011c2..26e0614bd4faa620 100644 --- a/tests/util/pattern.c +++ b/tests/util/pattern.c @@ -61,6 +61,20 @@ struct color_yuv { .u = MAKE_YUV_601_U(r, g, b), \ .v = MAKE_YUV_601_V(r, g, b) } +static inline uint32_t swap32(uint32_t x) +{ + return ((x & 0x000000ffU) << 24) | + ((x & 0x0000ff00U) << 8) | + ((x & 0x00ff0000U) >> 8) | + ((x & 0xff000000U) >> 24); +} + +#if defined(__BIG_ENDIAN__) || defined(__ARM_BIG_ENDIAN) || defined(__mc68000__) || defined(__MIPSEB__) || defined(__s390__) || defined(__sparc__) +#define cpu_to_le32(x) swap32(x) +#else +#define cpu_to_le32(x) (x) +#endif + /* This function takes 8-bit color values */ static inline uint32_t shiftcolor8(const struct util_color_component *comp, uint32_t value) @@ -520,26 +534,26 @@ static void fill_smpte_rgb32(const struct util_rgb_info *rgb, void *mem, for (y = 0; y < height * 6 / 9; ++y) { for (x = 0; x < width; ++x) - ((uint32_t *)mem)[x] = colors_top[x * 7 / width]; + ((uint32_t *)mem)[x] = cpu_to_le32(colors_top[x * 7 / width]); mem += stride; } for (; y < height * 7 / 9; ++y) { for (x = 0; x < width; ++x) - ((uint32_t *)mem)[x] = colors_middle[x * 7 / width]; + ((uint32_t *)mem)[x] = cpu_to_le32(colors_middle[x * 7 / width]); mem += stride; } for (; y < height; ++y) { for (x = 0; x < width * 5 / 7; ++x) ((uint32_t *)mem)[x] = - colors_bottom[x * 4 / (width * 5 / 7)]; + cpu_to_le32(colors_bottom[x * 4 / (width * 5 / 7)]); for (; x < width * 6 / 7; ++x) ((uint32_t *)mem)[x] = - colors_bottom[(x - width * 5 / 7) * 3 - / (width / 7) + 4]; + cpu_to_le32(colors_bottom[(x - width * 5 / 7) * 3 + / (width / 7) + 4]); for (; x < width; ++x) - ((uint32_t *)mem)[x] = colors_bottom[7]; + ((uint32_t *)mem)[x] = cpu_to_le32(colors_bottom[7]); mem += stride; } } @@ -1307,7 +1321,7 @@ static void fill_tiles_rgb32(const struct util_format_info *info, void *mem, (rgb32 >> 8) & 0xff, rgb32 & 0xff, alpha); - ((uint32_t *)mem)[x] = color; + ((uint32_t *)mem)[x] = cpu_to_le32(color); } mem += stride; } @@ -1454,7 +1468,7 @@ static void fill_gradient_rgb32(const struct util_rgb_info *rgb, for (j = 0; j < width / 2; j++) { uint32_t value = MAKE_RGBA10(rgb, j & 0x3ff, j & 0x3ff, j & 0x3ff, 0); - row[2*j] = row[2*j+1] = value; + row[2*j] = row[2*j+1] = cpu_to_le32(value); } mem += stride; } @@ -1464,7 +1478,7 @@ static void fill_gradient_rgb32(const struct util_rgb_info *rgb, for (j = 0; j < width / 2; j++) { uint32_t value = MAKE_RGBA10(rgb, j & 0x3fc, j & 0x3fc, j & 0x3fc, 0); - row[2*j] = row[2*j+1] = value; + row[2*j] = row[2*j+1] = cpu_to_le32(value); } mem += stride; } From patchwork Fri Jul 8 18:21:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 12911658 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 EAD12CCA47B for ; Fri, 8 Jul 2022 18:22:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 38FA410EBE4; Fri, 8 Jul 2022 18:21:59 +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 827BA10EBDF for ; Fri, 8 Jul 2022 18:21:53 +0000 (UTC) Received: from ramsan.of.borg ([84.195.186.194]) by laurent.telenet-ops.be with bizsmtp id siMt270054C55Sk01iMtsQ; 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 1o9sbw-002fNf-Qx; Fri, 08 Jul 2022 20:21:52 +0200 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1o9sbw-00BtV7-3W; Fri, 08 Jul 2022 20:21:52 +0200 From: Geert Uytterhoeven To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm v2 03/10] util: Fix 16 bpp patterns on big-endian Date: Fri, 8 Jul 2022 20:21:42 +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" DRM formats are defined to be little-endian, unless the DRM_FORMAT_BIG_ENDIAN flag is set. Hence writes of multi-byte pixel values need to take endianness into account. Introduce a swap16() helper to byteswap 16-bit values, and a cpu_to_le16() helper to convert 16-bit values from CPU-endian to little-endian, and use the latter in the various pattern fill functions for 16-bit formats. Signed-off-by: Geert Uytterhoeven --- Works now with both Linux' drm_fb_swab() and my own drm_fb_rgb565_to_rgb332_line() (the latter uses le16_to_cpu() to read pixel values from memory). v2: - New. --- tests/util/pattern.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/tests/util/pattern.c b/tests/util/pattern.c index 26e0614bd4faa620..c0bd382fbced90fb 100644 --- a/tests/util/pattern.c +++ b/tests/util/pattern.c @@ -61,6 +61,11 @@ struct color_yuv { .u = MAKE_YUV_601_U(r, g, b), \ .v = MAKE_YUV_601_V(r, g, b) } +static inline uint16_t swap16(uint16_t x) +{ + return ((x & 0x00ffU) << 8) | ((x & 0xff00U) >> 8); +} + static inline uint32_t swap32(uint32_t x) { return ((x & 0x000000ffU) << 24) | @@ -70,8 +75,10 @@ static inline uint32_t swap32(uint32_t x) } #if defined(__BIG_ENDIAN__) || defined(__ARM_BIG_ENDIAN) || defined(__mc68000__) || defined(__MIPSEB__) || defined(__s390__) || defined(__sparc__) +#define cpu_to_le16(x) swap16(x) #define cpu_to_le32(x) swap32(x) #else +#define cpu_to_le16(x) (x) #define cpu_to_le32(x) (x) #endif @@ -410,26 +417,26 @@ static void fill_smpte_rgb16(const struct util_rgb_info *rgb, void *mem, for (y = 0; y < height * 6 / 9; ++y) { for (x = 0; x < width; ++x) - ((uint16_t *)mem)[x] = colors_top[x * 7 / width]; + ((uint16_t *)mem)[x] = cpu_to_le16(colors_top[x * 7 / width]); mem += stride; } for (; y < height * 7 / 9; ++y) { for (x = 0; x < width; ++x) - ((uint16_t *)mem)[x] = colors_middle[x * 7 / width]; + ((uint16_t *)mem)[x] = cpu_to_le16(colors_middle[x * 7 / width]); mem += stride; } for (; y < height; ++y) { for (x = 0; x < width * 5 / 7; ++x) ((uint16_t *)mem)[x] = - colors_bottom[x * 4 / (width * 5 / 7)]; + cpu_to_le16(colors_bottom[x * 4 / (width * 5 / 7)]); for (; x < width * 6 / 7; ++x) ((uint16_t *)mem)[x] = - colors_bottom[(x - width * 5 / 7) * 3 - / (width / 7) + 4]; + cpu_to_le16(colors_bottom[(x - width * 5 / 7) * 3 + / (width / 7) + 4]); for (; x < width; ++x) - ((uint16_t *)mem)[x] = colors_bottom[7]; + ((uint16_t *)mem)[x] = cpu_to_le16(colors_bottom[7]); mem += stride; } } @@ -1272,7 +1279,7 @@ static void fill_tiles_rgb16(const struct util_format_info *info, void *mem, (rgb32 >> 8) & 0xff, rgb32 & 0xff, 255); - ((uint16_t *)mem)[x] = color; + ((uint16_t *)mem)[x] = cpu_to_le16(color); } mem += stride; } From patchwork Fri Jul 8 18:21:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 12911662 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 C9740C433EF for ; Fri, 8 Jul 2022 18:22:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 452DB10EC0E; Fri, 8 Jul 2022 18:22:03 +0000 (UTC) Received: from albert.telenet-ops.be (albert.telenet-ops.be [IPv6:2a02:1800:110:4::f00:1a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 8606710EBE1 for ; Fri, 8 Jul 2022 18:21:53 +0000 (UTC) Received: from ramsan.of.borg ([84.195.186.194]) by albert.telenet-ops.be with bizsmtp id siMt270084C55Sk06iMtcT; 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 1o9sbw-002fNg-Q8; Fri, 08 Jul 2022 20:21:52 +0200 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1o9sbw-00BtVE-47; Fri, 08 Jul 2022 20:21:52 +0200 From: Geert Uytterhoeven To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm v2 04/10] util: Add missing big-endian RGB16 frame buffer formats Date: Fri, 8 Jul 2022 20:21:43 +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" Signed-off-by: Geert Uytterhoeven --- Any better suggestion than appending "be"? v2: - New. --- tests/util/format.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/util/format.c b/tests/util/format.c index a5464de6fc1ac70f..42a652c9a402a654 100644 --- a/tests/util/format.c +++ b/tests/util/format.c @@ -76,6 +76,9 @@ static const struct util_format_info format_info[] = { { DRM_FORMAT_BGRX5551, "BX15", MAKE_RGB_INFO(5, 1, 5, 6, 5, 11, 0, 0) }, { DRM_FORMAT_RGB565, "RG16", MAKE_RGB_INFO(5, 11, 6, 5, 5, 0, 0, 0) }, { DRM_FORMAT_BGR565, "BG16", MAKE_RGB_INFO(5, 0, 6, 5, 5, 11, 0, 0) }, + /* Big-endian RGB16 */ + { DRM_FORMAT_XRGB1555 | DRM_FORMAT_BIG_ENDIAN, "XR15be", MAKE_RGB_INFO(5, 10, 5, 5, 5, 0, 0, 0) }, + { DRM_FORMAT_RGB565 | DRM_FORMAT_BIG_ENDIAN, "RG16be", MAKE_RGB_INFO(5, 11, 6, 5, 5, 0, 0, 0) }, /* RGB24 */ { DRM_FORMAT_BGR888, "BG24", MAKE_RGB_INFO(8, 0, 8, 8, 8, 16, 0, 0) }, { DRM_FORMAT_RGB888, "RG24", MAKE_RGB_INFO(8, 16, 8, 8, 8, 0, 0, 0) }, From patchwork Fri Jul 8 18:21:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 12911657 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 805A4C43334 for ; Fri, 8 Jul 2022 18:22:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5053A10EBE5; Fri, 8 Jul 2022 18:21:59 +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 6CBC710EBDE for ; Fri, 8 Jul 2022 18:21:53 +0000 (UTC) Received: from ramsan.of.borg ([84.195.186.194]) by laurent.telenet-ops.be with bizsmtp id siMt270014C55Sk01iMtsN; 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 1o9sbw-002fNh-KH; Fri, 08 Jul 2022 20:21:52 +0200 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1o9sbw-00BtVL-4i; Fri, 08 Jul 2022 20:21:52 +0200 From: Geert Uytterhoeven To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm v2 05/10] modetest: Fix printing of big-endian fourcc values Date: Fri, 8 Jul 2022 20:21:44 +0200 Message-Id: <0cd09c0b07e14a7e594bd86eaacbbeadb6c8f198.1657302103.git.geert@linux-m68k.org> 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" Big-endian fourcc values have the MSB set, as that is the DRM_FORMAT_BIG_ENDIAN flag. Hence printing the last byte unmodified leads to weird characters. Fix this by stripping the DRM_FORMAT_BIG_ENDIAN flag, and appending "be" for big-endian formats. Sample impact: Planes: id crtc fb CRTC x,y x,y gamma size possible crtcs 32 34 36 0,0 0,0 0 0x00000001 - formats: C1 C2 C4 C8 RG16 RG1� XR24 + formats: C1 C2 C4 C8 RG16 RG16be XR24 props: 8 type: flags: immutable enum enums: Overlay=0 Primary=1 Cursor=2 value: 1 30 IN_FORMATS: flags: immutable blob blobs: value: 00000001000000000000000700000018 00000001000000382020314320203243 202034432020384336314752b6314752 3432525800000000000000000000007f 00000000000000000000000000000000 in_formats blob decoded: C1 : LINEAR C2 : LINEAR C4 : LINEAR C8 : LINEAR RG16: LINEAR - RG1�: LINEAR + RG16be: LINEAR XR24: LINEAR Signed-off-by: Geert Uytterhoeven --- v2: - New. --- tests/modetest/modetest.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c index 1d87046f0fdfaf24..f70043d1e6815497 100644 --- a/tests/modetest/modetest.c +++ b/tests/modetest/modetest.c @@ -198,11 +198,15 @@ static bit_name_fn(mode_flag) static void dump_fourcc(uint32_t fourcc) { - printf(" %c%c%c%c", + bool be = fourcc & DRM_FORMAT_BIG_ENDIAN; + + fourcc &= ~DRM_FORMAT_BIG_ENDIAN; + printf(" %c%c%c%c%s", fourcc, fourcc >> 8, fourcc >> 16, - fourcc >> 24); + fourcc >> 24, + be ? "be" : ""); } static void dump_encoders(struct device *dev) 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"); } From patchwork Fri Jul 8 18:21:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 12911668 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 07FC2C433EF for ; Fri, 8 Jul 2022 18:22:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A213610EC03; Fri, 8 Jul 2022 18:22:02 +0000 (UTC) Received: from albert.telenet-ops.be (albert.telenet-ops.be [IPv6:2a02:1800:110:4::f00:1a]) by gabe.freedesktop.org (Postfix) with ESMTPS id CDB4910EBE6 for ; Fri, 8 Jul 2022 18:21:53 +0000 (UTC) Received: from ramsan.of.borg ([84.195.186.194]) by albert.telenet-ops.be with bizsmtp id siMt2700K4C55Sk06iMtcb; 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-002fNj-0v; Fri, 08 Jul 2022 20:21:53 +0200 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1o9sbw-00BtVZ-6O; Fri, 08 Jul 2022 20:21:52 +0200 From: Geert Uytterhoeven To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm v2 07/10] util: Add test pattern support for big-endian XRGB1555/RGB565 Date: Fri, 8 Jul 2022 20:21:46 +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" Add support for drawing the SMPTE and tiles test patterns in buffers using big-endian formats. For now this is limited to XRGB1555 and RGB565, which are the most common big-endian formats. Signed-off-by: Geert Uytterhoeven --- v2: - New. --- tests/util/pattern.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/tests/util/pattern.c b/tests/util/pattern.c index c0bd382fbced90fb..e693892bb3cf93c1 100644 --- a/tests/util/pattern.c +++ b/tests/util/pattern.c @@ -23,6 +23,7 @@ * IN THE SOFTWARE. */ +#include #include #include #include @@ -75,13 +76,17 @@ static inline uint32_t swap32(uint32_t x) } #if defined(__BIG_ENDIAN__) || defined(__ARM_BIG_ENDIAN) || defined(__mc68000__) || defined(__MIPSEB__) || defined(__s390__) || defined(__sparc__) +#define cpu_to_be16(x) (x) #define cpu_to_le16(x) swap16(x) #define cpu_to_le32(x) swap32(x) #else +#define cpu_to_be16(x) swap16(x) #define cpu_to_le16(x) (x) #define cpu_to_le32(x) (x) #endif +#define cpu_to_fb16(x) (fb_be ? cpu_to_be16(x) : cpu_to_le16(x)) + /* This function takes 8-bit color values */ static inline uint32_t shiftcolor8(const struct util_color_component *comp, uint32_t value) @@ -382,7 +387,7 @@ static void fill_smpte_yuv_packed(const struct util_yuv_info *yuv, void *mem, static void fill_smpte_rgb16(const struct util_rgb_info *rgb, void *mem, unsigned int width, unsigned int height, - unsigned int stride) + unsigned int stride, bool fb_be) { const uint16_t colors_top[] = { MAKE_RGBA(rgb, 192, 192, 192, 255), /* grey */ @@ -417,26 +422,26 @@ static void fill_smpte_rgb16(const struct util_rgb_info *rgb, void *mem, for (y = 0; y < height * 6 / 9; ++y) { for (x = 0; x < width; ++x) - ((uint16_t *)mem)[x] = cpu_to_le16(colors_top[x * 7 / width]); + ((uint16_t *)mem)[x] = cpu_to_fb16(colors_top[x * 7 / width]); mem += stride; } for (; y < height * 7 / 9; ++y) { for (x = 0; x < width; ++x) - ((uint16_t *)mem)[x] = cpu_to_le16(colors_middle[x * 7 / width]); + ((uint16_t *)mem)[x] = cpu_to_fb16(colors_middle[x * 7 / width]); mem += stride; } for (; y < height; ++y) { for (x = 0; x < width * 5 / 7; ++x) ((uint16_t *)mem)[x] = - cpu_to_le16(colors_bottom[x * 4 / (width * 5 / 7)]); + cpu_to_fb16(colors_bottom[x * 4 / (width * 5 / 7)]); for (; x < width * 6 / 7; ++x) ((uint16_t *)mem)[x] = - cpu_to_le16(colors_bottom[(x - width * 5 / 7) * 3 + cpu_to_fb16(colors_bottom[(x - width * 5 / 7) * 3 / (width / 7) + 4]); for (; x < width; ++x) - ((uint16_t *)mem)[x] = cpu_to_le16(colors_bottom[7]); + ((uint16_t *)mem)[x] = cpu_to_fb16(colors_bottom[7]); mem += stride; } } @@ -1081,9 +1086,11 @@ static void fill_smpte(const struct util_format_info *info, void *planes[3], case DRM_FORMAT_BGRA4444: case DRM_FORMAT_BGRX4444: case DRM_FORMAT_RGB565: + case DRM_FORMAT_RGB565 | DRM_FORMAT_BIG_ENDIAN: case DRM_FORMAT_BGR565: case DRM_FORMAT_ARGB1555: case DRM_FORMAT_XRGB1555: + case DRM_FORMAT_XRGB1555 | DRM_FORMAT_BIG_ENDIAN: case DRM_FORMAT_ABGR1555: case DRM_FORMAT_XBGR1555: case DRM_FORMAT_RGBA5551: @@ -1091,7 +1098,8 @@ static void fill_smpte(const struct util_format_info *info, void *planes[3], case DRM_FORMAT_BGRA5551: case DRM_FORMAT_BGRX5551: return fill_smpte_rgb16(&info->rgb, planes[0], - width, height, stride); + width, height, stride, + info->format & DRM_FORMAT_BIG_ENDIAN); case DRM_FORMAT_BGR888: case DRM_FORMAT_RGB888: @@ -1263,7 +1271,7 @@ static void fill_tiles_yuv_packed(const struct util_format_info *info, static void fill_tiles_rgb16(const struct util_format_info *info, void *mem, unsigned int width, unsigned int height, - unsigned int stride) + unsigned int stride, bool fb_be) { const struct util_rgb_info *rgb = &info->rgb; void *mem_base = mem; @@ -1279,7 +1287,7 @@ static void fill_tiles_rgb16(const struct util_format_info *info, void *mem, (rgb32 >> 8) & 0xff, rgb32 & 0xff, 255); - ((uint16_t *)mem)[x] = cpu_to_le16(color); + ((uint16_t *)mem)[x] = cpu_to_fb16(color); } mem += stride; } @@ -1401,9 +1409,11 @@ static void fill_tiles(const struct util_format_info *info, void *planes[3], case DRM_FORMAT_BGRA4444: case DRM_FORMAT_BGRX4444: case DRM_FORMAT_RGB565: + case DRM_FORMAT_RGB565 | DRM_FORMAT_BIG_ENDIAN: case DRM_FORMAT_BGR565: case DRM_FORMAT_ARGB1555: case DRM_FORMAT_XRGB1555: + case DRM_FORMAT_XRGB1555 | DRM_FORMAT_BIG_ENDIAN: case DRM_FORMAT_ABGR1555: case DRM_FORMAT_XBGR1555: case DRM_FORMAT_RGBA5551: @@ -1411,7 +1421,8 @@ static void fill_tiles(const struct util_format_info *info, void *planes[3], case DRM_FORMAT_BGRA5551: case DRM_FORMAT_BGRX5551: return fill_tiles_rgb16(info, planes[0], - width, height, stride); + width, height, stride, + info->format & DRM_FORMAT_BIG_ENDIAN); case DRM_FORMAT_BGR888: case DRM_FORMAT_RGB888: From patchwork Fri Jul 8 18:21:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 12911666 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 CB807C433EF for ; Fri, 8 Jul 2022 18:22:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0BE4010EC07; Fri, 8 Jul 2022 18:22:03 +0000 (UTC) Received: from michel.telenet-ops.be (michel.telenet-ops.be [IPv6:2a02:1800:110:4::f00:18]) by gabe.freedesktop.org (Postfix) with ESMTPS id E414C10EBD9 for ; Fri, 8 Jul 2022 18:21:53 +0000 (UTC) Received: from ramsan.of.borg ([84.195.186.194]) by michel.telenet-ops.be with bizsmtp id siMt2700J4C55Sk06iMtm6; 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-002fNk-2D; Fri, 08 Jul 2022 20:21:53 +0200 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1o9sbw-00BtVg-7b; Fri, 08 Jul 2022 20:21:52 +0200 From: Geert Uytterhoeven To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm v2 08/10] util: Fix pwetty on big-endian Date: Fri, 8 Jul 2022 20:21:47 +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" Cairo always uses native byte order for rendering. Hence if the byte order of the frame buffer differs from the byte order of the CPU, the frame buffer contents need to be byteswapped twice: once before rendering, to convert to native byte order, and a second time after rendering, to restore the frame buffer format's byte order. Note that byte swapping is not done for ARGB32 formats, as for these formats, byte order only affects the order of the red, green, and blue channels, which we do not care about here. Signed-off-by: Geert Uytterhoeven --- This is ugly, but I see no better solution. v2: - RGB30 is untested. --- tests/util/pattern.c | 54 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/tests/util/pattern.c b/tests/util/pattern.c index e693892bb3cf93c1..627f402be1d02e1c 100644 --- a/tests/util/pattern.c +++ b/tests/util/pattern.c @@ -76,13 +76,15 @@ static inline uint32_t swap32(uint32_t x) } #if defined(__BIG_ENDIAN__) || defined(__ARM_BIG_ENDIAN) || defined(__mc68000__) || defined(__MIPSEB__) || defined(__s390__) || defined(__sparc__) -#define cpu_to_be16(x) (x) -#define cpu_to_le16(x) swap16(x) -#define cpu_to_le32(x) swap32(x) +#define cpu_to_be16(x) (x) +#define cpu_to_le16(x) swap16(x) +#define cpu_to_le32(x) swap32(x) +#define fb_foreign_endian(format) (!((format) & DRM_FORMAT_BIG_ENDIAN)) #else -#define cpu_to_be16(x) swap16(x) -#define cpu_to_le16(x) (x) -#define cpu_to_le32(x) (x) +#define cpu_to_be16(x) swap16(x) +#define cpu_to_le16(x) (x) +#define cpu_to_le32(x) (x) +#define fb_foreign_endian(format) ((format) & DRM_FORMAT_BIG_ENDIAN) #endif #define cpu_to_fb16(x) (fb_be ? cpu_to_be16(x) : cpu_to_le16(x)) @@ -1133,6 +1135,30 @@ static void fill_smpte(const struct util_format_info *info, void *planes[3], #define GREEN 1 #define BLUE 0 +static void byteswap_buffer16(void *mem, unsigned int width, unsigned int height, + unsigned int stride) +{ + unsigned int x, y; + + for (y = 0; y < height; ++y) { + for (x = 0; x < width; ++x) + ((uint16_t *)mem)[x] = swap16(((uint16_t *)mem)[x]); + mem += stride; + } +} + +static void byteswap_buffer32(void *mem, unsigned int width, unsigned int height, + unsigned int stride) +{ + unsigned int x, y; + + for (y = 0; y < height; ++y) { + for (x = 0; x < width; ++x) + ((uint32_t *)mem)[x] = swap32(((uint32_t *)mem)[x]); + mem += stride; + } +} + static void make_pwetty(void *data, unsigned int width, unsigned int height, unsigned int stride, uint32_t format) { @@ -1140,6 +1166,8 @@ static void make_pwetty(void *data, unsigned int width, unsigned int height, cairo_surface_t *surface; cairo_t *cr; cairo_format_t cairo_format; + bool swap16 = false; + bool swap32 = false; /* we can ignore the order of R,G,B channels */ switch (format) { @@ -1152,6 +1180,7 @@ static void make_pwetty(void *data, unsigned int width, unsigned int height, case DRM_FORMAT_RGB565: case DRM_FORMAT_BGR565: cairo_format = CAIRO_FORMAT_RGB16_565; + swap16 = fb_foreign_endian(format); break; #if CAIRO_VERSION_MAJOR > 1 || (CAIRO_VERSION_MAJOR == 1 && CAIRO_VERSION_MINOR >= 12) case DRM_FORMAT_ARGB2101010: @@ -1159,12 +1188,19 @@ static void make_pwetty(void *data, unsigned int width, unsigned int height, case DRM_FORMAT_ABGR2101010: case DRM_FORMAT_XBGR2101010: cairo_format = CAIRO_FORMAT_RGB30; + swap32 = fb_foreign_endian(format); break; #endif default: return; } + /* Cairo uses native byte order, so we may have to byteswap before... */ + if (swap16) + byteswap_buffer16(data, width, height, stride); + if (swap32) + byteswap_buffer32(data, width, height, stride); + surface = cairo_image_surface_create_for_data(data, cairo_format, width, height, @@ -1200,6 +1236,12 @@ static void make_pwetty(void *data, unsigned int width, unsigned int height, } cairo_destroy(cr); + + /* ... and after */ + if (swap16) + byteswap_buffer16(data, width, height, stride); + if (swap32) + byteswap_buffer32(data, width, height, stride); #endif } From patchwork Fri Jul 8 18:21:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 12911667 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 CDE89C43334 for ; Fri, 8 Jul 2022 18:22:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A777110EC04; Fri, 8 Jul 2022 18:22:02 +0000 (UTC) Received: from albert.telenet-ops.be (albert.telenet-ops.be [IPv6:2a02:1800:110:4::f00:1a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 97E1E10EBE4 for ; Fri, 8 Jul 2022 18:21:53 +0000 (UTC) Received: from ramsan.of.borg ([84.195.186.194]) by albert.telenet-ops.be with bizsmtp id siMt2700D4C55Sk06iMtcX; 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 1o9sbw-002fNn-Te; Fri, 08 Jul 2022 20:21:52 +0200 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from ) id 1o9sbw-00BtVn-8k; Fri, 08 Jul 2022 20:21:52 +0200 From: Geert Uytterhoeven To: dri-devel@lists.freedesktop.org Subject: [PATCH libdrm v2 09/10] util: Add pwetty support for big-endian RGB565 Date: Fri, 8 Jul 2022 20:21:48 +0200 Message-Id: <7956f2485b6d6ea11860736417a2122cf2e2cd6e.1657302103.git.geert@linux-m68k.org> 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" Add support for rendering the crosshairs in a buffer using the big-endian RGB565 format. Signed-off-by: Geert Uytterhoeven --- v2: - New. --- tests/util/pattern.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/util/pattern.c b/tests/util/pattern.c index 627f402be1d02e1c..1222b47ea3f14cd0 100644 --- a/tests/util/pattern.c +++ b/tests/util/pattern.c @@ -1178,6 +1178,7 @@ static void make_pwetty(void *data, unsigned int width, unsigned int height, cairo_format = CAIRO_FORMAT_ARGB32; break; case DRM_FORMAT_RGB565: + case DRM_FORMAT_RGB565 | DRM_FORMAT_BIG_ENDIAN: case DRM_FORMAT_BGR565: cairo_format = CAIRO_FORMAT_RGB16_565; swap16 = fb_foreign_endian(format);