Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3527483rwb; Tue, 16 Aug 2022 04:50:54 -0700 (PDT) X-Google-Smtp-Source: AA6agR5EVkiT0wY8KgFxDFB3nuATCT6CYXTEa7CKFcNjthWM+7+Qp2jr+a7KvEkiV9/LXGMzlelN X-Received: by 2002:a05:6a00:ac4:b0:535:c08:2da7 with SMTP id c4-20020a056a000ac400b005350c082da7mr6078761pfl.69.1660650654095; Tue, 16 Aug 2022 04:50:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660650654; cv=none; d=google.com; s=arc-20160816; b=dBmdk+2M2TyI/w/kVEPI79YuLh7yMW8wpVsRvTBIdBsAUZxdCdoQxaoBHaK0FuX4ff g9mmxnZdc1jbj3E9FEdiRjAhAF/uYGlr7ExgCsBSvH/ZyIEeNNckYUYN8FOhijrRXywg 3zodmH6+DQmjAMP6ZC9BWP1M9j66gP/Kxgz/KyvVUdr3nSzw/MoC3X/WuB1qvF+wvTUl UnxqTMvoAI0pZA18R0uPkmhHetbnPtdNZAqJjCIz4o/ysUlu0jThw99TVgXSabu7efQr tomlBDqIYJ9rfcCRx7BFSN61pouXoz/mHvIrSP3g2z0LgijP1mOAhxMwrx1lU8FJHmQT CUxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/7pcMlkWYdqvd9nF4xjztw1PEhSKdH6W+Iikd1ByWuw=; b=ytJ/Qmq+Mx7MQzaIQWp7mPzpzAT+2llpjmUkLBMZnjvcvZ11CSYxqXYpYcENWE+8Z7 /ol5z13FahfvoKHVBb6F8GVHHoLtJfq0U6z/tXuba+qm3EDzLMp31p1Z0RBxfVzrrHL/ 2TFT9usf66ZSDjR76ZtzUlCDPzulnObnMuq6drumhEoxYzBt9Md2KkuysrCcdE+Wqr3A mWeb6+jn+WWVdmoIfB5qlW4O5qxWOKxGTvMdMgn2OYx0VZk1jNYfZmfbYyxmPs/zjjuw 3XrkrlCRQpsP1WH63CIfaEtKCaEsZqyCAynSsMLWN6n2bf82Mv/Y1fE5UkDEHvhlxI96 q2Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=fjgXliTQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o19-20020a17090ac09300b001f4dd42e18dsi1712688pjs.10.2022.08.16.04.50.42; Tue, 16 Aug 2022 04:50:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=fjgXliTQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235146AbiHPLBU (ORCPT + 99 others); Tue, 16 Aug 2022 07:01:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235201AbiHPLAo (ORCPT ); Tue, 16 Aug 2022 07:00:44 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6210C877F for ; Tue, 16 Aug 2022 03:29:15 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id s23so5013352wmj.4 for ; Tue, 16 Aug 2022 03:29:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=/7pcMlkWYdqvd9nF4xjztw1PEhSKdH6W+Iikd1ByWuw=; b=fjgXliTQmp5AXMdjyj5BNorQm9b2QUgkuF9SUN7Rt5bCG3Yq9Kr1x94ZifYm+8nVx0 inz8PqyRLDZjqb5gY81bWFL0yvLSIjXMVAKdCo8E5qpHS2UAhTiT/w55V1fR2cD5Pd2B 1Rx+cRG/T9KhAKwyGRinIsjzPbukSldQFl1GGVizLBrfm1XMPI72YWtoNtMgkYEmKW05 TXbTLePLT8qZVgAgEuCwywy9mlzdoK4LGNXQ3/iGFhUMp7OpcHa3REKtRBee4KGA151v 8ho4BL9+LhpURGEzBp4FXtfYChdegmjZyBxMB5w8yIaqOYOy9rxlBIE1yRCag9ZeJB1e IxVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=/7pcMlkWYdqvd9nF4xjztw1PEhSKdH6W+Iikd1ByWuw=; b=VR8RXm1H15u+rIpFm2Vrqbgjq1blSAMfI+FTbEOH9oLB9tNsGBbJFeoZfgrD7nKQVT MUIs5svfOq6rV0Fc3Kg5erpZ4aNbUQ8Ek6DqreN2QJASsZw2E6QC8hNr1ILzEGsvs4vZ lC9sEqT/4nS9P/WWjDf+RJ3JLcjQRWKjzjwH0DtE64I9msxZ3Yz/jAs0ui03pU+Bo8lV jtbACa7qHS522gCJh0+uY0spif0CpsplSnpVuHp2Jg4KZzvklv1CmDEUiMDBONhB8TIe rnCJmN4MR/X0is1OQ7m2rY1VMiNFovVL9CPkjPndK3iKz5Qn8WPXV6pWuG1myQ3Ivkto 6H0g== X-Gm-Message-State: ACgBeo2NsjUp3lLD2l7fSrkKtULT+oI8+FGCHnxs6NnMyy7wHtLW46Ad 81LStLsc11Cg605NBqf5ugY= X-Received: by 2002:a05:600c:1f08:b0:3a5:e8d6:ddd2 with SMTP id bd8-20020a05600c1f0800b003a5e8d6ddd2mr7393277wmb.57.1660645753401; Tue, 16 Aug 2022 03:29:13 -0700 (PDT) Received: from localhost.localdomain ([94.73.32.249]) by smtp.gmail.com with ESMTPSA id m9-20020adffe49000000b002251639bfd0sm1668407wrs.59.2022.08.16.03.29.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Aug 2022 03:29:13 -0700 (PDT) From: =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= To: javierm@redhat.com Cc: davidgow@google.com, dlatypov@google.com, tzimmermann@suse.de, mripard@kernel.org, daniel@ffwll.ch, airlied@linux.ie, maarten.lankhorst@linux.intel.com, jani.nikula@linux.intel.com, maira.canal@usp.br, isabbasso@riseup.net, magalilemes00@gmail.com, tales.aparecida@gmail.com, geert@linux-m68k.org, dri-devel@lists.freedesktop.org, kunit-dev@googlegroups.com, linux-kernel@vger.kernel.org, =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= Subject: [PATCH 1/3] drm/format-helper: Add KUnit tests for drm_fb_xrgb8888_to_rgb888() Date: Tue, 16 Aug 2022 12:29:01 +0200 Message-Id: <20220816102903.276879-2-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220816102903.276879-1-jose.exposito89@gmail.com> References: <20220816102903.276879-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Extend the existing test cases to test the conversion from XRGB8888 to RGB888. Signed-off-by: José Expósito --- .../gpu/drm/tests/drm_format_helper_test.c | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c index 828487071796..08d08e7ab19a 100644 --- a/drivers/gpu/drm/tests/drm_format_helper_test.c +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c @@ -27,6 +27,11 @@ struct convert_to_rgb565_result { const u16 expected_swab[TEST_BUF_SIZE]; }; +struct convert_to_rgb888_result { + unsigned int dst_pitch; + const u8 expected[TEST_BUF_SIZE]; +}; + struct convert_xrgb8888_case { const char *name; unsigned int pitch; @@ -34,6 +39,7 @@ struct convert_xrgb8888_case { const u32 xrgb8888[TEST_BUF_SIZE]; struct convert_to_rgb332_result rgb332_result; struct convert_to_rgb565_result rgb565_result; + struct convert_to_rgb888_result rgb888_result; }; static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { @@ -51,6 +57,10 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { .expected = { 0xF800 }, .expected_swab = { 0x00F8 }, }, + .rgb888_result = { + .dst_pitch = 0, + .expected = { 0x00, 0x00, 0xFF }, + }, }, { .name = "single_pixel_clip_rectangle", @@ -69,6 +79,10 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { .expected = { 0xF800 }, .expected_swab = { 0x00F8 }, }, + .rgb888_result = { + .dst_pitch = 0, + .expected = { 0x00, 0x00, 0xFF }, + }, }, { /* Well known colors: White, black, red, green, blue, magenta, @@ -109,6 +123,15 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { 0xE0FF, 0xFF07, }, }, + .rgb888_result = { + .dst_pitch = 0, + .expected = { + 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, + 0xFF, 0x00, 0x00, 0xFF, 0x00, 0xFF, + 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, + }, + }, }, { /* Randomly picked colors. Full buffer within the clip area. */ @@ -141,6 +164,17 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { 0x00A8, 0x8E6B, 0x330A, 0x0000, 0x0000, }, }, + .rgb888_result = { + .dst_pitch = 15, + .expected = { + 0x9C, 0x44, 0x0E, 0x05, 0x4D, 0x11, 0x03, 0x03, 0xA8, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x73, 0x70, 0x6C, 0x9C, 0x44, 0x0E, 0x05, 0x4D, 0x11, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03, 0x03, 0xA8, 0x73, 0x70, 0x6C, 0x9C, 0x44, 0x0E, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + }, + }, }, }; @@ -255,9 +289,40 @@ static void xrgb8888_to_rgb565_test(struct kunit *test) KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected_swab, dst_size), 0); } +static void xrgb8888_to_rgb888_test(struct kunit *test) +{ + const struct convert_xrgb8888_case *params = test->param_value; + const struct convert_to_rgb888_result *result = ¶ms->rgb888_result; + size_t dst_size; + __u8 *buf = NULL; + __u32 *xrgb8888 = NULL; + struct iosys_map dst, src; + + struct drm_framebuffer fb = { + .format = drm_format_info(DRM_FORMAT_XRGB8888), + .pitches = { params->pitch, 0, 0 }, + }; + + dst_size = conversion_buf_size(DRM_FORMAT_RGB888, result->dst_pitch, + ¶ms->clip); + KUNIT_ASSERT_GT(test, dst_size, 0); + + buf = kunit_kzalloc(test, dst_size, GFP_KERNEL); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buf); + iosys_map_set_vaddr(&dst, buf); + + xrgb8888 = le32buf_to_cpu(test, params->xrgb8888, TEST_BUF_SIZE); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, xrgb8888); + iosys_map_set_vaddr(&src, xrgb8888); + + drm_fb_xrgb8888_to_rgb888(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip); + KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, 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), + KUNIT_CASE_PARAM(xrgb8888_to_rgb888_test, convert_xrgb8888_gen_params), {} }; -- 2.25.1