Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp2203896rwb; Mon, 19 Sep 2022 01:00:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6UcGoxJUEbcSQQ8WAvcx8SbFtP6ECbtulPUP1XTDCZwkhBSTpCjxXZai4yBOSlJgEDDTtl X-Received: by 2002:a17:903:248:b0:172:7520:db07 with SMTP id j8-20020a170903024800b001727520db07mr11760215plh.76.1663574415293; Mon, 19 Sep 2022 01:00:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663574415; cv=none; d=google.com; s=arc-20160816; b=UVLmrcKYwcW2pBr9JI2jyUOGlWsmRv7T22X9WEZmdMBj/8rPw5lRCH8fgieBo217PM rNUOKTC0R05//OXn1AdFii1hNTeW3V9Fkw4V6IJ+OBfDcgwI8oNR9lejBgv/nOu2C8Qu F7Ksk83H8jZXwHbzmpQlzFt2jDQbaVbGxxAPNqGz2QU3aepnyaOSPtue47Eyr92J86nN y1MGWPzYLQVm5mWW5WWp9SQDk3CSu6Cvap2k2+tV7QkqBeB1KkipDhoUrXSC0cdj1hGy Bhqq/H6tQjDV02nQ8MMJXgc857KuM5nGVF1xlBAy8HyMMatjwjw7qbWDxXIXIdX6/+XF Y08g== 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=Y+/9Eo/+FGAJXwWdsnxjUOBvrjDggVecVUqEpljQ8Wk=; b=qzEMfp7BkakGjGMDOePRSlJxJSKGyVldif4p+8xmcJ5vfp8eo07foNz5PtJrcqgI8a kdxhAQUIu4W6BpjZmCjhhaoYAHlyMn+hipwgKKa41C6oVwQW7jVHgMS69PuSdSLDb8eD KSnICl/mZ23NONax2DqnYPlqdp4Th9En3kPJU8/zVNXHZki2CZJW0TxEsnUqP3cEZQE3 S7BWNBBpYafDoDQD03Mm2X9+SPXXPkRLEVvr3RHg9uHWnHzEICtPXYf/S0OaP7ltmksm OUZf6OPAAhXPE6mga6Toqs9I2ngrHy4DPXi6lRbNobwjcERbU8nUjtosngY+iISd0/ZN hx2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="ViUfs/eB"; 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 r8-20020a635148000000b0042bba5a062csi8971397pgl.280.2022.09.19.01.00.03; Mon, 19 Sep 2022 01:00:15 -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="ViUfs/eB"; 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 S229870AbiISHP6 (ORCPT + 99 others); Mon, 19 Sep 2022 03:15:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229827AbiISHPr (ORCPT ); Mon, 19 Sep 2022 03:15:47 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 759BE13F79 for ; Mon, 19 Sep 2022 00:15:45 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id k9so46092428wri.0 for ; Mon, 19 Sep 2022 00:15:45 -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:subject:date; bh=Y+/9Eo/+FGAJXwWdsnxjUOBvrjDggVecVUqEpljQ8Wk=; b=ViUfs/eBqECjm7D7VWc7N4a82hDDl4MzRy5bhTYFej2oWh9Y+dzSw5MOyCoWiuZQpM Ji+iy79Z9ZFmZ3Xtxfmb4VEeN8rnjIBZTaqi0dqoVZJvNChhdlw/qBX6MH7FcdLSknRC /iyc2Xw5lFLahewd1ROXvKYQswYWjecUX6gTSSP2iJZHNBhbnf/p38HU4IqqH7ptsh1O NWADMLOd2TvjlHburh5KMwoNZpbe+jMrOM/q/mDlbjDadkpgSVJtkAd5+8JABPZTSQRM dPEusn487wgbVEMqXuTNN9njMcOqRpPWyp+40+cFAfUFU9Vo402J9PGBFRIsGQHsg38P 860A== 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 :subject:date; bh=Y+/9Eo/+FGAJXwWdsnxjUOBvrjDggVecVUqEpljQ8Wk=; b=15hrVzTDMd7zGBNUb7mZsYYjPf7jLvgRl9jcflmRV9VgObUFAjPoEFQxhSQaTh+pUW A6Q2gkE0SYjAwYhS6FMuXppJasfYxZ9jNeHq1GAXBgta9Q/1110MyaVce3bot/sCospd Dj4RRdWNG1DQ3PUuVvPv10WIFqdoaWG8c5sFgzElgffrAqPM/PDROXVdY67vJYZyYJMr vprsnMWc3GKNny2bCFxktoMztpuAtBAbNjyDuReuqxqbGBReaubkzm4swYg2PyNHa+Ns +Dgvx7J7sfoo0r2Ary8KMxUgPd9jc3WHU3B+aS9a9bFXu1RbwVqpD7AoW9oQXSmRCCjC Trkw== X-Gm-Message-State: ACrzQf0lVrpB/wdlRX6UYnjJsfuqPZvUV06tcwUm5HBov6HAglSmzxE1 a6iRAgUWvRiaVMj+RIjMOEY= X-Received: by 2002:a5d:6852:0:b0:228:c94b:a5b0 with SMTP id o18-20020a5d6852000000b00228c94ba5b0mr9382436wrw.540.1663571743768; Mon, 19 Sep 2022 00:15:43 -0700 (PDT) Received: from localhost.localdomain ([94.73.32.249]) by smtp.gmail.com with ESMTPSA id l3-20020a5d4bc3000000b0022ac12fff29sm12864564wrt.65.2022.09.19.00.15.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Sep 2022 00:15:43 -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 v4 2/3] drm/format-helper: Add KUnit tests for drm_fb_xrgb8888_to_xrgb2101010() Date: Mon, 19 Sep 2022 09:15:30 +0200 Message-Id: <20220919071531.105124-3-jose.exposito89@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220919071531.105124-1-jose.exposito89@gmail.com> References: <20220919071531.105124-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.8 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 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 XRGB2101010. In order to be able to call drm_fb_xrgb8888_to_xrgb2101010() when compiling CONFIG_DRM_KMS_HELPER as a module export the symbol. Tested-by: Maíra Canal Reviewed-by: David Gow Signed-off-by: José Expósito --- drivers/gpu/drm/drm_format_helper.c | 1 + .../gpu/drm/tests/drm_format_helper_test.c | 63 +++++++++++++++++++ 2 files changed, 64 insertions(+) diff --git a/drivers/gpu/drm/drm_format_helper.c b/drivers/gpu/drm/drm_format_helper.c index 4afc4ac27342..e2f76621453c 100644 --- a/drivers/gpu/drm/drm_format_helper.c +++ b/drivers/gpu/drm/drm_format_helper.c @@ -553,6 +553,7 @@ void drm_fb_xrgb8888_to_xrgb2101010(struct iosys_map *dst, const unsigned int *d drm_fb_xfrm(dst, dst_pitch, dst_pixsize, src, fb, clip, false, drm_fb_xrgb8888_to_xrgb2101010_line); } +EXPORT_SYMBOL(drm_fb_xrgb8888_to_xrgb2101010); static void drm_fb_xrgb8888_to_gray8_line(void *dbuf, const void *sbuf, unsigned int pixels) { diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c index cc1ab672314a..09d358b54da0 100644 --- a/drivers/gpu/drm/tests/drm_format_helper_test.c +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c @@ -32,6 +32,11 @@ struct convert_to_rgb888_result { const u8 expected[TEST_BUF_SIZE]; }; +struct convert_to_xrgb2101010_result { + unsigned int dst_pitch; + const u32 expected[TEST_BUF_SIZE]; +}; + struct convert_xrgb8888_case { const char *name; unsigned int pitch; @@ -40,6 +45,7 @@ struct convert_xrgb8888_case { struct convert_to_rgb332_result rgb332_result; struct convert_to_rgb565_result rgb565_result; struct convert_to_rgb888_result rgb888_result; + struct convert_to_xrgb2101010_result xrgb2101010_result; }; static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { @@ -61,6 +67,10 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { .dst_pitch = 0, .expected = { 0x00, 0x00, 0xFF }, }, + .xrgb2101010_result = { + .dst_pitch = 0, + .expected = { 0x3FF00000 }, + }, }, { .name = "single_pixel_clip_rectangle", @@ -83,6 +93,10 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { .dst_pitch = 0, .expected = { 0x00, 0x00, 0xFF }, }, + .xrgb2101010_result = { + .dst_pitch = 0, + .expected = { 0x3FF00000 }, + }, }, { /* Well known colors: White, black, red, green, blue, magenta, @@ -132,6 +146,15 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, }, }, + .xrgb2101010_result = { + .dst_pitch = 0, + .expected = { + 0x3FFFFFFF, 0x00000000, + 0x3FF00000, 0x000FFC00, + 0x000003FF, 0x3FF003FF, + 0x3FFFFC00, 0x000FFFFF, + }, + }, }, { /* Randomly picked colors. Full buffer within the clip area. */ @@ -175,6 +198,14 @@ static struct convert_xrgb8888_case convert_xrgb8888_cases[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }, }, + .xrgb2101010_result = { + .dst_pitch = 20, + .expected = { + 0x03844672, 0x0444D414, 0x2A20300C, 0x00000000, 0x00000000, + 0x1B1705CD, 0x03844672, 0x0444D414, 0x00000000, 0x00000000, + 0x2A20300C, 0x1B1705CD, 0x03844672, 0x00000000, 0x00000000, + }, + }, }, }; @@ -319,10 +350,42 @@ static void drm_test_fb_xrgb8888_to_rgb888_test(struct kunit *test) KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0); } +static void drm_test_fb_xrgb8888_to_xrgb2101010_test(struct kunit *test) +{ + const struct convert_xrgb8888_case *params = test->param_value; + const struct convert_to_xrgb2101010_result *result = ¶ms->xrgb2101010_result; + size_t dst_size; + __u32 *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_XRGB2101010, + 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_xrgb2101010(&dst, &result->dst_pitch, &src, &fb, ¶ms->clip); + buf = le32buf_to_cpu(test, buf, TEST_BUF_SIZE); + KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0); +} + static struct kunit_case drm_format_helper_test_cases[] = { KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb332, convert_xrgb8888_gen_params), KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb565, convert_xrgb8888_gen_params), KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb888_test, convert_xrgb8888_gen_params), + KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_xrgb2101010_test, convert_xrgb8888_gen_params), {} }; -- 2.25.1