From patchwork Tue Jul 26 23:09:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 12929921 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 743B1C00144 for ; Tue, 26 Jul 2022 23:09:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6D999B214A; Tue, 26 Jul 2022 23:09:36 +0000 (UTC) Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 545CCB20F8 for ; Tue, 26 Jul 2022 23:09:29 +0000 (UTC) Received: by mail-wr1-x42a.google.com with SMTP id h9so22066681wrm.0 for ; Tue, 26 Jul 2022 16:09:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+WjHwX17IyVtE8JB1105eRfVv2sAKL5cPl31La/xOQo=; b=VGK4nGWHPp+fpD4KWPsFdVLzQoUwu3AS2ZsPPS1d9SDhBhj4jsgK1a7w4mr+kiRkVk sV7TSqPh4d6SYELXugNc5Mfxum2KHCm8lFD/01gYXW6nAcSDeg0RO8OzNPA5FOOqa05Q uK1doUC+LZxBh2JvADCr/aUKb44C1/HMSu105vww/VzpGa1cG1pE3t2ZGTCL0fpowSL0 aDKIa5XiEpnEhMERgglzPkq9wEMMscvQ4UGkllAI4EHWy3cn0d0U9WlT1Ewf+xLAjrh2 /5mycI6+I2DWcUo+3+pqTJdBA6s0BnnCdzza9UfjvVdUogQxTqoB3bPIkc+rI3lBg/B+ vJkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+WjHwX17IyVtE8JB1105eRfVv2sAKL5cPl31La/xOQo=; b=MFV6H2a8bI5DqRKUL6k1cnejTb4x1FiFEA0dEGO7DxvuBt5QCU/3mz+47mk++B+7lc o6p1Cx5yp1/K6KgYRQVIbhn8tMJaAnPQRNcyHFSfzS3nwZEQIFK0xiqy9msImixSd1of zVrTJ9rm3jo9QyQepzB8ajUNLKGA9UbT5M7Y/QmmFyGNapD9g73e2iFmTPHFOiqfijjV evnr9eWyYkEKDRJytwgIU4A4RpCUWcjvRiACVaJP0P6T85EoizyCqHYN5L6R7U/f4/i6 uZM6DblEcXf55CuDqVLH8sozeqYFYZSHYB0ZR2OfoD7Hgj2L9IzaGgwNV1QpRZ3XN6kG 6RSw== X-Gm-Message-State: AJIora81ivNunMlslQGK4x0qm1UQTqXcN/ByPcl13Pa3I6WKjO5N6MxX 25yoHici2BbxvJAbdgJn4bA= X-Google-Smtp-Source: AGRyM1v/fQQzGFvnnr7oKrY5P9zFJMTTvyjTxfnbA8sJj+wpsxKlBRi5cRJ61oLJ48N2T6oZihddRg== X-Received: by 2002:adf:e70e:0:b0:21d:7f90:7501 with SMTP id c14-20020adfe70e000000b0021d7f907501mr11552680wrm.447.1658876967632; Tue, 26 Jul 2022 16:09:27 -0700 (PDT) Received: from localhost.localdomain ([94.73.33.57]) by smtp.gmail.com with ESMTPSA id bn20-20020a056000061400b0021e86504736sm7278533wrb.16.2022.07.26.16.09.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 16:09:27 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: javierm@redhat.com Subject: [PATCH v3 1/4] drm/format-helper: Fix test on big endian architectures Date: Wed, 27 Jul 2022 01:09:13 +0200 Message-Id: <20220726230916.390575-2-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220726230916.390575-1-jose.exposito89@gmail.com> References: <20220726230916.390575-1-jose.exposito89@gmail.com> 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: dri-devel@lists.freedesktop.org, tzimmermann@suse.de, magalilemes00@gmail.com, airlied@linux.ie, maira.canal@usp.br, dlatypov@google.com, linux-kernel@vger.kernel.org, geert@linux-m68k.org, tales.aparecida@gmail.com, davidgow@google.com, =?utf-8?b?Sm9zw6kgRXhww7Nz?= =?utf-8?b?aXRv?= , isabbasso@riseup.net, kunit-dev@googlegroups.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The tests fail on big endian architectures, like PowerPC: $ ./tools/testing/kunit/kunit.py run \ --kunitconfig=drivers/gpu/drm/tests \ --arch=powerpc --cross_compile=powerpc64-linux-gnu- Transform the XRGB8888 buffer from little endian to the CPU endian before calling the conversion function to avoid this error. Fixes: 8f456104915f ("drm/format-helper: Add KUnit tests for drm_fb_xrgb8888_to_rgb332()") Reported-by: David Gow Reviewed-by: David Gow Signed-off-by: José Expósito --- .../gpu/drm/tests/drm_format_helper_test.c | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c index 98583bf56044..eefaba3aaea2 100644 --- a/drivers/gpu/drm/tests/drm_format_helper_test.c +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c @@ -111,6 +111,21 @@ static size_t conversion_buf_size(u32 dst_format, unsigned int dst_pitch, return dst_pitch * drm_rect_height(clip); } +static u32 *le32buf_to_cpu(struct kunit *test, const u32 *buf, size_t buf_size) +{ + u32 *dst = NULL; + int n; + + dst = kunit_kzalloc(test, sizeof(*dst) * buf_size, GFP_KERNEL); + if (!dst) + return NULL; + + for (n = 0; n < buf_size; n++) + dst[n] = le32_to_cpu((__force __le32)buf[n]); + + return dst; +} + static void xrgb8888_to_rgb332_case_desc(struct xrgb8888_to_rgb332_case *t, char *desc) { @@ -125,6 +140,7 @@ static void xrgb8888_to_rgb332_test(struct kunit *test) const struct xrgb8888_to_rgb332_case *params = test->param_value; size_t dst_size; __u8 *dst = NULL; + __u32 *src = NULL; struct drm_framebuffer fb = { .format = drm_format_info(DRM_FORMAT_XRGB8888), @@ -138,8 +154,11 @@ static void xrgb8888_to_rgb332_test(struct kunit *test) dst = kunit_kzalloc(test, dst_size, GFP_KERNEL); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dst); - drm_fb_xrgb8888_to_rgb332(dst, params->dst_pitch, params->xrgb8888, - &fb, ¶ms->clip); + src = le32buf_to_cpu(test, params->xrgb8888, TEST_BUF_SIZE); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, src); + + drm_fb_xrgb8888_to_rgb332(dst, params->dst_pitch, src, &fb, + ¶ms->clip); KUNIT_EXPECT_EQ(test, memcmp(dst, params->expected, dst_size), 0); } From patchwork Tue Jul 26 23:09:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 12929920 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 49FCCC19F29 for ; Tue, 26 Jul 2022 23:09:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 71F2BB20FF; Tue, 26 Jul 2022 23:09:35 +0000 (UTC) Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by gabe.freedesktop.org (Postfix) with ESMTPS id B2FA9B2137 for ; Tue, 26 Jul 2022 23:09:33 +0000 (UTC) Received: by mail-wr1-x42e.google.com with SMTP id l22so466181wrz.7 for ; Tue, 26 Jul 2022 16:09:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IXBbfu9mH+3+82kkU4IAZXAEpzI0pj7x/+D2ozToh5w=; b=NPv3yuIQbsQLMH7RsnBBqh/qdJLdGbIa0IDae1WJu0k0Lgagakni4QySN5ufrp9P4O sif0hRkblEt+rTBcvEIy4EXFb1WBRinXkxxKwELgZhAuF3wt8CKBGG60r8oI4LgsWdGP 87+sKBoWp94lRiKoeqTo44xD4MmmfXXtpdRi8GKy9rSfSgQWGzDuh31GY4qmgQZxoYpO iJBEqJlUr+iGd0uacoQAaB/ovVyJ2T5cAa9lPce8RRqiVa7ygPtXQynKgkTZKmrsfAls jOPBIt5JfsDT8Yo3z8LFnLmWpOwRXB7JJqC0dlmEUGgML9uCFX6kpCaN7FHfsfW1Mq5E VASA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IXBbfu9mH+3+82kkU4IAZXAEpzI0pj7x/+D2ozToh5w=; b=vwPZGz/Mf4qffbN5I8ZFG0Q5/oLYna9F+0qP9u+uKcbTmhtA95L03roMvVbOIDs1MH Iycs15gN8K46vAEYKJstensDfDrjWyrJzp0ZNRWWMIIO4n/DS9xn5hEx9YEYhnW0CwbY Lz9aEZIA5ajy+zjOp5YGL/Q2LzJiFy6gXH7aU+O8qR7ISS8ycjjNCuggjPv6/aI4rDbv 8SILQ+JaqpvS6vv73A13a0/2t75lqgCtHQVn+FRJz+sqrX39Y8OXbVKsn5g409DTFKkh HQrl0pFm7PWw7LyafVUedwO/ZEn6JzBc9VH/vR0j5vsThqaPoCMLImTS8gGj7MK8mTYW y/5w== X-Gm-Message-State: AJIora/HqXlNaVI0SnhZfSig03F9xf0jnRzlsf1LuuJPh3hz5x810Zu9 7Zdu36LB/6HIItd3Shw6o0s= X-Google-Smtp-Source: AGRyM1tWEYsb37uk6QjZIBeHdz8zdF3zgTaiG38PwXMzYHyAoZm5sRjiG4hj2tmDVSOwHofPYB7brg== X-Received: by 2002:a5d:64ec:0:b0:21e:92fe:ac77 with SMTP id g12-20020a5d64ec000000b0021e92feac77mr5802206wri.24.1658876972259; Tue, 26 Jul 2022 16:09:32 -0700 (PDT) Received: from localhost.localdomain ([94.73.33.57]) by smtp.gmail.com with ESMTPSA id bn20-20020a056000061400b0021e86504736sm7278533wrb.16.2022.07.26.16.09.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 16:09:32 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: javierm@redhat.com Subject: [PATCH v3 2/4] drm/format-helper: Rename test cases to make them more generic Date: Wed, 27 Jul 2022 01:09:14 +0200 Message-Id: <20220726230916.390575-3-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220726230916.390575-1-jose.exposito89@gmail.com> References: <20220726230916.390575-1-jose.exposito89@gmail.com> 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: dri-devel@lists.freedesktop.org, tzimmermann@suse.de, magalilemes00@gmail.com, airlied@linux.ie, maira.canal@usp.br, dlatypov@google.com, linux-kernel@vger.kernel.org, geert@linux-m68k.org, tales.aparecida@gmail.com, davidgow@google.com, =?utf-8?b?Sm9zw6kgRXhww7Nz?= =?utf-8?b?aXRv?= , isabbasso@riseup.net, kunit-dev@googlegroups.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The tests available at the moment only check the conversion from XRGB8888 to RGB332. However, more conversions will be tested in the future. In order to make the struct and functions present in the tests more generic, rename xrgb8888_to_rgb332_* to convert_xrgb8888_*. Tested-by: Tales L. Aparecida Acked-by: Thomas Zimmermann Reviewed-by: David Gow Signed-off-by: José Expósito --- drivers/gpu/drm/tests/drm_format_helper_test.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c index eefaba3aaea2..97fccd0a948b 100644 --- a/drivers/gpu/drm/tests/drm_format_helper_test.c +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c @@ -16,7 +16,7 @@ #define TEST_BUF_SIZE 50 -struct xrgb8888_to_rgb332_case { +struct convert_xrgb8888_case { const char *name; unsigned int pitch; unsigned int dst_pitch; @@ -25,7 +25,7 @@ struct xrgb8888_to_rgb332_case { const u8 expected[4 * TEST_BUF_SIZE]; }; -static struct xrgb8888_to_rgb332_case xrgb8888_to_rgb332_cases[] = { +static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { { .name = "single_pixel_source_buffer", .pitch = 1 * 4, @@ -126,18 +126,18 @@ static u32 *le32buf_to_cpu(struct kunit *test, const u32 *buf, size_t buf_size) return dst; } -static void xrgb8888_to_rgb332_case_desc(struct xrgb8888_to_rgb332_case *t, - char *desc) +static void convert_xrgb8888_case_desc(struct convert_xrgb8888_case *t, + char *desc) { strscpy(desc, t->name, KUNIT_PARAM_DESC_SIZE); } -KUNIT_ARRAY_PARAM(xrgb8888_to_rgb332, xrgb8888_to_rgb332_cases, - xrgb8888_to_rgb332_case_desc); +KUNIT_ARRAY_PARAM(convert_xrgb8888, convert_xrgb8888_cases, + convert_xrgb8888_case_desc); static void xrgb8888_to_rgb332_test(struct kunit *test) { - const struct xrgb8888_to_rgb332_case *params = test->param_value; + const struct convert_xrgb8888_case *params = test->param_value; size_t dst_size; __u8 *dst = NULL; __u32 *src = NULL; @@ -163,8 +163,7 @@ static void xrgb8888_to_rgb332_test(struct kunit *test) } static struct kunit_case drm_format_helper_test_cases[] = { - KUNIT_CASE_PARAM(xrgb8888_to_rgb332_test, - xrgb8888_to_rgb332_gen_params), + KUNIT_CASE_PARAM(xrgb8888_to_rgb332_test, convert_xrgb8888_gen_params), {} }; From patchwork Tue Jul 26 23:09:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 12929922 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 A1128C00144 for ; Tue, 26 Jul 2022 23:09:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6FC95B2182; Tue, 26 Jul 2022 23:09:44 +0000 (UTC) Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by gabe.freedesktop.org (Postfix) with ESMTPS id BD762B2152 for ; Tue, 26 Jul 2022 23:09:37 +0000 (UTC) Received: by mail-wm1-x333.google.com with SMTP id id17so9589229wmb.1 for ; Tue, 26 Jul 2022 16:09:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7LYSq8hx22ya/0Q3RDvIrYgbye9rn19b0dTSWrS2MZM=; b=WJpJeqqBlqEKk0b1mJ5CveY8VUPsEHlGwStJlju/fjlQIqyBtyY3i9Nkaw+YpjqgO0 tSbd2o1UUpgIdJabjsf027FDVfMI5J9Hx9vfQ4Ci5R3ig5DOT3Yv01xIIBozDJjcmGnv sxScyjPM0t9QkJzI1wXgs3nq/gFrT5QHaBiotFK623XlcYyUOLWYYjpx9p4s8tIiSFgV N91vIbhhXy/zUh3ueEpfyvpm47jknl8pk5vjSgB/V9eD9c161oumNDq0rPPnIwsxfOfo pfkduQMCIlIVRoOaJBDqazfLRN40b7mnzC8JqPkrO7Ye0EKQihXyiMTDxECQ5fLuSlO9 0Vgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7LYSq8hx22ya/0Q3RDvIrYgbye9rn19b0dTSWrS2MZM=; b=PzNkMTBmP9y5crLX/6AgtOSYnY8FN0apmVmqptapCM7DHtiZIwvK0u0TjSFFlHytqk pDCzVv8h8XGf0X6EdOFHpYfbDZpN5/brrt7rr6wptN0+9Ys5JHZ5hse0ndSZj25jMwub 5haU7VjrUkgUwY8IosZtb+Nww9w/rM5Woq6wi/Mj7urMEanYyFLNaoLGApf8GMiVGa4l qDxfce0L/xoT+aI9/7bv1ADT2H/Uo+N8C/IaohIX0dhencJfvrF37EwB2jRimpgfTfjn LMCAPcl62GvBSm51vIIji3fcvR29Gd9BJgBySa/GRSW6eZ/Bk0r1laPBG3uFtqLBjRXw UWqg== X-Gm-Message-State: AJIora/uGOJ0POl5fuQbwK8SzXMEzKrz5+rHx5UCBdE01GDnso9fYeHS zHyhj8UKMgsIfFIOuktEm7c= X-Google-Smtp-Source: AGRyM1vKbx3uskTJG4AMUYgWTzQlKU/ObH5liOKJRFdwjqBSWmpqBt2RoO2l9iwU1IggMhb5832kdQ== X-Received: by 2002:a7b:c391:0:b0:3a3:2f22:7bf6 with SMTP id s17-20020a7bc391000000b003a32f227bf6mr903333wmj.96.1658876975722; Tue, 26 Jul 2022 16:09:35 -0700 (PDT) Received: from localhost.localdomain ([94.73.33.57]) by smtp.gmail.com with ESMTPSA id bn20-20020a056000061400b0021e86504736sm7278533wrb.16.2022.07.26.16.09.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 16:09:35 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: javierm@redhat.com Subject: [PATCH v3 3/4] drm/format-helper: Support multiple target formats results Date: Wed, 27 Jul 2022 01:09:15 +0200 Message-Id: <20220726230916.390575-4-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220726230916.390575-1-jose.exposito89@gmail.com> References: <20220726230916.390575-1-jose.exposito89@gmail.com> 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: dri-devel@lists.freedesktop.org, tzimmermann@suse.de, magalilemes00@gmail.com, airlied@linux.ie, maira.canal@usp.br, dlatypov@google.com, linux-kernel@vger.kernel.org, geert@linux-m68k.org, tales.aparecida@gmail.com, davidgow@google.com, =?utf-8?b?Sm9zw6kgRXhww7Nz?= =?utf-8?b?aXRv?= , isabbasso@riseup.net, kunit-dev@googlegroups.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" In order to support multiple destination format conversions, store the destination pitch and the expected result in its own structure. Tested-by: Tales L. Aparecida Acked-by: Thomas Zimmermann Reviewed-by: David Gow Signed-off-by: José Expósito --- .../gpu/drm/tests/drm_format_helper_test.c | 53 ++++++++++++------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c index 97fccd0a948b..bbe9e9f57e2b 100644 --- a/drivers/gpu/drm/tests/drm_format_helper_test.c +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c @@ -16,34 +16,42 @@ #define TEST_BUF_SIZE 50 +struct convert_to_rgb332_result { + unsigned int dst_pitch; + const u8 expected[TEST_BUF_SIZE]; +}; + struct convert_xrgb8888_case { const char *name; unsigned int pitch; - unsigned int dst_pitch; struct drm_rect clip; const u32 xrgb8888[TEST_BUF_SIZE]; - const u8 expected[4 * TEST_BUF_SIZE]; + struct convert_to_rgb332_result rgb332_result; }; static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { { .name = "single_pixel_source_buffer", .pitch = 1 * 4, - .dst_pitch = 0, .clip = DRM_RECT_INIT(0, 0, 1, 1), .xrgb8888 = { 0x01FF0000 }, - .expected = { 0xE0 }, + .rgb332_result = { + .dst_pitch = 0, + .expected = { 0xE0 }, + }, }, { .name = "single_pixel_clip_rectangle", .pitch = 2 * 4, - .dst_pitch = 0, .clip = DRM_RECT_INIT(1, 1, 1, 1), .xrgb8888 = { 0x00000000, 0x00000000, 0x00000000, 0x10FF0000, }, - .expected = { 0xE0 }, + .rgb332_result = { + .dst_pitch = 0, + .expected = { 0xE0 }, + }, }, { /* Well known colors: White, black, red, green, blue, magenta, @@ -52,7 +60,6 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { */ .name = "well_known_colors", .pitch = 4 * 4, - .dst_pitch = 0, .clip = DRM_RECT_INIT(1, 1, 2, 4), .xrgb8888 = { 0x00000000, 0x00000000, 0x00000000, 0x00000000, @@ -61,28 +68,33 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { 0x00000000, 0x550000FF, 0x66FF00FF, 0x00000000, 0x00000000, 0x77FFFF00, 0x8800FFFF, 0x00000000, }, - .expected = { - 0xFF, 0x00, - 0xE0, 0x1C, - 0x03, 0xE3, - 0xFC, 0x1F, + .rgb332_result = { + .dst_pitch = 0, + .expected = { + 0xFF, 0x00, + 0xE0, 0x1C, + 0x03, 0xE3, + 0xFC, 0x1F, + }, }, }, { /* Randomly picked colors. Full buffer within the clip area. */ .name = "destination_pitch", .pitch = 3 * 4, - .dst_pitch = 5, .clip = DRM_RECT_INIT(0, 0, 3, 3), .xrgb8888 = { 0xA10E449C, 0xB1114D05, 0xC1A80303, 0xD16C7073, 0xA20E449C, 0xB2114D05, 0xC2A80303, 0xD26C7073, 0xA30E449C, }, - .expected = { - 0x0A, 0x08, 0xA0, 0x00, 0x00, - 0x6D, 0x0A, 0x08, 0x00, 0x00, - 0xA0, 0x6D, 0x0A, 0x00, 0x00, + .rgb332_result = { + .dst_pitch = 5, + .expected = { + 0x0A, 0x08, 0xA0, 0x00, 0x00, + 0x6D, 0x0A, 0x08, 0x00, 0x00, + 0xA0, 0x6D, 0x0A, 0x00, 0x00, + }, }, }, }; @@ -138,6 +150,7 @@ KUNIT_ARRAY_PARAM(convert_xrgb8888, convert_xrgb8888_cases, static void xrgb8888_to_rgb332_test(struct kunit *test) { const struct convert_xrgb8888_case *params = test->param_value; + const struct convert_to_rgb332_result *result = ¶ms->rgb332_result; size_t dst_size; __u8 *dst = NULL; __u32 *src = NULL; @@ -147,7 +160,7 @@ static void xrgb8888_to_rgb332_test(struct kunit *test) .pitches = { params->pitch, 0, 0 }, }; - dst_size = conversion_buf_size(DRM_FORMAT_RGB332, params->dst_pitch, + dst_size = conversion_buf_size(DRM_FORMAT_RGB332, result->dst_pitch, ¶ms->clip); KUNIT_ASSERT_GT(test, dst_size, 0); @@ -157,9 +170,9 @@ static void xrgb8888_to_rgb332_test(struct kunit *test) src = le32buf_to_cpu(test, params->xrgb8888, TEST_BUF_SIZE); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, src); - drm_fb_xrgb8888_to_rgb332(dst, params->dst_pitch, src, &fb, + drm_fb_xrgb8888_to_rgb332(dst, result->dst_pitch, src, &fb, ¶ms->clip); - KUNIT_EXPECT_EQ(test, memcmp(dst, params->expected, dst_size), 0); + KUNIT_EXPECT_EQ(test, memcmp(dst, result->expected, dst_size), 0); } static struct kunit_case drm_format_helper_test_cases[] = { From patchwork Tue Jul 26 23:09:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= X-Patchwork-Id: 12929923 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 DCA5DC00144 for ; Tue, 26 Jul 2022 23:09:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 27CB6B216C; Tue, 26 Jul 2022 23:09:45 +0000 (UTC) Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by gabe.freedesktop.org (Postfix) with ESMTPS id 292DFB217D for ; Tue, 26 Jul 2022 23:09:41 +0000 (UTC) Received: by mail-wm1-x32a.google.com with SMTP id x23-20020a05600c179700b003a30e3e7989so162288wmo.0 for ; Tue, 26 Jul 2022 16:09:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oIjUYYBOwxHZn2ecu0MuwO5iaRLwywmUHAZ/RS0frQw=; b=PqZn57nRt/sCz7jZKRta1WifqaGU2h37re/DwH9LCZBTRxoNWTI++D2Dp3kj2ysqiM LYtTKrDQhzwYN1/YjfK2/wDy472NHnQFPN4TdMrOwoLRD9rYniY/s/nKHEDtz38mM4bi bkNe0Cj6GFp6EBAju3sxhRXizbUq/k4czy2U/eoD1H5u9KQKcNdBKnC321c3NqmyqNJJ +b4QfLC6LRWCwLHGylL3CkmbwcNhyn+KuaQjHo0ehtaOSjylgDG0zy/mzukLmHhJMiHx +odLlZdoIVxtWnM4Kd/IOJbH7oJAGd1jge5fBcnhy3pyFOqXjKAcoxWxkFQ0Oe8C89eS 3xnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oIjUYYBOwxHZn2ecu0MuwO5iaRLwywmUHAZ/RS0frQw=; b=TYXl6+rbMNDw5Z3ulFJzg7lYWG80mlPDPC212XwRXdAgAgg4ylaYWNCvT1HkXYsNHa 4JjiM74eTipPEVxpfwwwJ6Cm+UQenYJRQJw/n1RiYH5lOz4xY8P7I1DjkxbUMTChI8SA MvwLaKJKaHnEygKIq2sAJwpRUCwCKnKukvxl+xtxGKaiTU3VzC0GSOUamcg+6lhenE11 lUcA7v/3IoubCIbv+gksSKee2IcdIsB0LY7uieJVMm8r190HJBgQ6imnUBoe1H5EdVc3 AaD8/oSboK/qZICWuGLVwvif4li5JqZtfLE/s7Ia1X1X7f4mntn0ZItwukuFoslHPcQo rEGQ== X-Gm-Message-State: AJIora9hGuCW/nSnUr7YB+IFNKo8sl6rDv/YxjLbA+pTUEEPfVLR8FHi kyDploHdQ79kgw87LuP9fYOnFZp53KefTA== X-Google-Smtp-Source: AGRyM1tFLDABFVLuRLqINt1PGPt0nzQwUF/dvYsheoH0cu1MNlLHcJRKMS2POHcSl1iiA+F0/AolnA== X-Received: by 2002:a05:600c:2056:b0:3a3:2cf8:ec9 with SMTP id p22-20020a05600c205600b003a32cf80ec9mr870387wmg.51.1658876979381; Tue, 26 Jul 2022 16:09:39 -0700 (PDT) Received: from localhost.localdomain ([94.73.33.57]) by smtp.gmail.com with ESMTPSA id bn20-20020a056000061400b0021e86504736sm7278533wrb.16.2022.07.26.16.09.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Jul 2022 16:09:39 -0700 (PDT) From: =?utf-8?b?Sm9zw6kgRXhww7NzaXRv?= To: javierm@redhat.com Subject: [PATCH v3 4/4] drm/format-helper: Add KUnit tests for drm_fb_xrgb8888_to_rgb565() Date: Wed, 27 Jul 2022 01:09:16 +0200 Message-Id: <20220726230916.390575-5-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220726230916.390575-1-jose.exposito89@gmail.com> References: <20220726230916.390575-1-jose.exposito89@gmail.com> 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: dri-devel@lists.freedesktop.org, tzimmermann@suse.de, magalilemes00@gmail.com, airlied@linux.ie, maira.canal@usp.br, dlatypov@google.com, linux-kernel@vger.kernel.org, geert@linux-m68k.org, tales.aparecida@gmail.com, davidgow@google.com, =?utf-8?b?Sm9zw6kgRXhww7Nz?= =?utf-8?b?aXRv?= , isabbasso@riseup.net, kunit-dev@googlegroups.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Extend the existing test cases to test the conversion from XRGB8888 to RGB565. The documentation and the color picker available on [1] are useful resources to understand this patch and validate the values returned by the conversion function. Tested-by: Tales L. Aparecida Acked-by: Thomas Zimmermann Reviewed-by: David Gow Signed-off-by: José Expósito Link: http://www.barth-dev.de/online/rgb565-color-picker/ # [1] --- .../gpu/drm/tests/drm_format_helper_test.c | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c index bbe9e9f57e2b..26ecf3b4b137 100644 --- a/drivers/gpu/drm/tests/drm_format_helper_test.c +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c @@ -21,12 +21,19 @@ struct convert_to_rgb332_result { const u8 expected[TEST_BUF_SIZE]; }; +struct convert_to_rgb565_result { + unsigned int dst_pitch; + const u16 expected[TEST_BUF_SIZE]; + const u16 expected_swab[TEST_BUF_SIZE]; +}; + struct convert_xrgb8888_case { const char *name; unsigned int pitch; struct drm_rect clip; const u32 xrgb8888[TEST_BUF_SIZE]; struct convert_to_rgb332_result rgb332_result; + struct convert_to_rgb565_result rgb565_result; }; static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { @@ -39,6 +46,11 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { .dst_pitch = 0, .expected = { 0xE0 }, }, + .rgb565_result = { + .dst_pitch = 0, + .expected = { 0xF800 }, + .expected_swab = { 0x00F8 }, + }, }, { .name = "single_pixel_clip_rectangle", @@ -52,6 +64,11 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { .dst_pitch = 0, .expected = { 0xE0 }, }, + .rgb565_result = { + .dst_pitch = 0, + .expected = { 0xF800 }, + .expected_swab = { 0x00F8 }, + }, }, { /* Well known colors: White, black, red, green, blue, magenta, @@ -77,6 +94,21 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { 0xFC, 0x1F, }, }, + .rgb565_result = { + .dst_pitch = 0, + .expected = { + 0xFFFF, 0x0000, + 0xF800, 0x07E0, + 0x001F, 0xF81F, + 0xFFE0, 0x07FF, + }, + .expected_swab = { + 0xFFFF, 0x0000, + 0x00F8, 0xE007, + 0x1F00, 0x1FF8, + 0xE0FF, 0xFF07, + }, + }, }, { /* Randomly picked colors. Full buffer within the clip area. */ @@ -96,6 +128,19 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { 0xA0, 0x6D, 0x0A, 0x00, 0x00, }, }, + .rgb565_result = { + .dst_pitch = 10, + .expected = { + 0x0A33, 0x1260, 0xA800, 0x0000, 0x0000, + 0x6B8E, 0x0A33, 0x1260, 0x0000, 0x0000, + 0xA800, 0x6B8E, 0x0A33, 0x0000, 0x0000, + }, + .expected_swab = { + 0x330A, 0x6012, 0x00A8, 0x0000, 0x0000, + 0x8E6B, 0x330A, 0x6012, 0x0000, 0x0000, + 0x00A8, 0x8E6B, 0x330A, 0x0000, 0x0000, + }, + }, }, }; @@ -175,8 +220,41 @@ static void xrgb8888_to_rgb332_test(struct kunit *test) KUNIT_EXPECT_EQ(test, memcmp(dst, result->expected, dst_size), 0); } +static void xrgb8888_to_rgb565_test(struct kunit *test) +{ + const struct convert_xrgb8888_case *params = test->param_value; + const struct convert_to_rgb565_result *result = ¶ms->rgb565_result; + size_t dst_size; + __u16 *dst = NULL; + __u32 *src = NULL; + + struct drm_framebuffer fb = { + .format = drm_format_info(DRM_FORMAT_XRGB8888), + .pitches = { params->pitch, 0, 0 }, + }; + + dst_size = conversion_buf_size(DRM_FORMAT_RGB565, result->dst_pitch, + ¶ms->clip); + KUNIT_ASSERT_GT(test, dst_size, 0); + + dst = kunit_kzalloc(test, dst_size, GFP_KERNEL); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dst); + + src = le32buf_to_cpu(test, params->xrgb8888, TEST_BUF_SIZE); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, src); + + drm_fb_xrgb8888_to_rgb565(dst, result->dst_pitch, src, &fb, + ¶ms->clip, false); + KUNIT_EXPECT_EQ(test, memcmp(dst, result->expected, dst_size), 0); + + drm_fb_xrgb8888_to_rgb565(dst, result->dst_pitch, src, &fb, + ¶ms->clip, true); + KUNIT_EXPECT_EQ(test, memcmp(dst, result->expected_swab, dst_size), 0); +} + static struct kunit_case drm_format_helper_test_cases[] = { KUNIT_CASE_PARAM(xrgb8888_to_rgb332_test, convert_xrgb8888_gen_params), + KUNIT_CASE_PARAM(xrgb8888_to_rgb565_test, convert_xrgb8888_gen_params), {} };