Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp2060888rwe; Sun, 28 Aug 2022 02:58:12 -0700 (PDT) X-Google-Smtp-Source: AA6agR7725K5aFc0BGViGLKINfaZiH1N4P05Aa8o+saJqs8N59d1qf17yKNvDTEWjnhjDbIY8ONo X-Received: by 2002:a65:6944:0:b0:41b:4483:35cc with SMTP id w4-20020a656944000000b0041b448335ccmr10129125pgq.296.1661680692000; Sun, 28 Aug 2022 02:58:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661680691; cv=none; d=google.com; s=arc-20160816; b=EkkaYQozCjhAHDd1asTSyXcwzZYqijrUEuOR2oncds3rOfPmxGenSYIk8lWCXj9kOh CzUQ9nG+rTd6//vA43gbZ4WSHLVRR6ESK92xfJb7yLxhmtENzqoTSGGt7+e0Ek9Ztajj 0P0vqHT8Tf1mZRjpWX6u4qHNsaZtIIs2n37xHNH7EuI1nSkvUu83TxsJynemZdJqkajk q5oDf1x3IUYbsheqdUunSXSHM0iUsl4a4W7J4cw+NEN9nA//BjAG7ejBDIXIEe6RRZD1 MrKzp9spIQ9U2T4mFN0bovMD5UdbZmWgcpFQKTKWBFUUBGYsCyp+xvirSyJ+ArniRWfc cicQ== 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=vJhh/lTctUSQJ2j9ZuvCFA+0ks2hV9Sn9L7SV18NIxM=; b=fxfmitvV8nC4eFBWooz9fIfKFoBlUkRuhDYhLQGdmUQYWA/Ghxum1/IGkhpQuCKyHc G4Gf6fhJCY7WvucEd7BVP6vzFTYZVKAVZwW9/W6nvhMJT0L2VOp2y6VCZLvAEBVDW8yl FE4q3rLZFByTufBzVNfpoW8uqjhgojrimVO74ajZ2fF3N+z7vh8hCS6NRVmmLTVtSaIU eXS3gxIVJ1ECjU/oVkAJv+5UdrwGRSKG/3ra/SdB0ljPlc7dmec9yGQVaODJL5FGkO0I NpkTUlZX3WSqKfjNRpqR7k2QzkieiryAs4lk+yRzIoupfz7XBA3U+cEZBVyZpCzFuWdK zpfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=L82H8gYU; 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 w11-20020a63474b000000b0041b578f7150si6542079pgk.701.2022.08.28.02.58.00; Sun, 28 Aug 2022 02:58:11 -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=L82H8gYU; 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 S230198AbiH1JBe (ORCPT + 99 others); Sun, 28 Aug 2022 05:01:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229777AbiH1JBb (ORCPT ); Sun, 28 Aug 2022 05:01:31 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF39C3ED5D for ; Sun, 28 Aug 2022 02:01:30 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id h5so6657831wru.7 for ; Sun, 28 Aug 2022 02:01:30 -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=vJhh/lTctUSQJ2j9ZuvCFA+0ks2hV9Sn9L7SV18NIxM=; b=L82H8gYUNi1ZNwNb/Q6+xIcjId3rBJ2ZLHZOoVJPNM+EwIBmlLRilZtqTAuVhg8xkP 7pIrIUUZNa9pSj2JNwS60ZVJHOJ6umJAKqMWz3n+GZPQ0/m6itbCGub1FxLbrSSVdfx+ XGrTU/gJcuMwehSLbhbwTDzrvXf/AV60pCt6FKWjIeicdoudl05DezUDqm9Y0MvJGxrW WbOcuJcDk11UkU9QouRHV0D2dhkNiA/PNHRH1n8ughScFDQ0da0vrwqihJmwb99l5eir D9vh44wTKQUjdhv3hk9e/DPQQyEe4EDoU3xITkG+aS/3vYTphScZgRwyb06dgZx4rWVp 34bg== 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=vJhh/lTctUSQJ2j9ZuvCFA+0ks2hV9Sn9L7SV18NIxM=; b=Jt0qtlPVsJGZVc6n/n6kQ0eIlt8Jtj2RSPXKyuNqODU7obOxk3q8h+u3vQEBKO2nSl Npe+EbiiMX1R1N6u16O2XYoifM23OZvWNRGy63Ywsi49YrJa1es7NswBDbK6YI0qYiYk t/h9masNuN6w9kJDP6VVW/2o1u5pXr2YcYMY9/lzGEuvWMULbmjXwivN7KCG6Bs55qQI fLrLUg3PjGdtWE32CkBv2bqfAOm6f2/k8MM1UsfQ6sxqJ8pZbRUUWd1f976K5b1wfzzE C9e5HeGIPGD8SvngJ/+Tu8JTmSCh2Pw+0Y1pfe9YPpQDZbCIVjAyESpA4Eev/ArpOfK5 9D/g== X-Gm-Message-State: ACgBeo1i9T5Shw6C3IennMwaEjo7RIDP1/pfAff0LQrHGqJAwAN9d+s9 Iatqy4K/hhlT/aId5Ln/Cz8= X-Received: by 2002:adf:fa4e:0:b0:225:8616:be3a with SMTP id y14-20020adffa4e000000b002258616be3amr3574741wrr.234.1661677289383; Sun, 28 Aug 2022 02:01:29 -0700 (PDT) Received: from localhost.localdomain ([94.73.32.249]) by smtp.gmail.com with ESMTPSA id h18-20020a05600c351200b003a60ff7c082sm5733425wmq.15.2022.08.28.02.01.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Aug 2022 02:01:29 -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?= , =?UTF-8?q?Ma=C3=ADra=20Canal?= Subject: [PATCH v2 1/3] drm/format-helper: Add KUnit tests for drm_fb_xrgb8888_to_rgb888() Date: Sun, 28 Aug 2022 11:01:19 +0200 Message-Id: <20220828090121.13243-2-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220828090121.13243-1-jose.exposito89@gmail.com> References: <20220828090121.13243-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. Tested-by: Maíra Canal Reviewed-by: David Gow 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