From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E0121ECAAD3 for ; Mon, 19 Sep 2022 07:36:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229826AbiISHgy (ORCPT ); Mon, 19 Sep 2022 03:36:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229813AbiISHgv (ORCPT ); Mon, 19 Sep 2022 03:36:51 -0400 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBA7E1EADF for ; Mon, 19 Sep 2022 00:36:49 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 283A25C027B; Mon, 19 Sep 2022 03:36:49 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Mon, 19 Sep 2022 03:36:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1663573009; x= 1663659409; bh=ivBFTb4mJwy/p2/PscYsL8xWxc9ankAdkoVS7A7AZgY=; b=o 1v8uTT0BWdWJxC8KNrRmrVTHnlI4MCsc7HsvF03en7CLSGRlVUPhI8aml1gZ2lie v8bhDBxBIdCFVHXbGaugmC4KQz4tD9PJNarMO8iuqX2VYqd/Q/jMHTBYIwrocYD5 0bNeyn/28mrMwQYXKiohxRuEitT6iZVoH4NKEw+e8LVNfIUGe9lH7KIBy6fb4UGu AFBgPiNmRpss1bJgPUENoSy/z/chM+G8LQ3vA6EiK3KTCNF6X3+w5VA7Xz57KLqH VTePxMFKVwjjUDK1JNdr0UVvRRLYhmyJNCV4XyrQFpQQXDbIWdiHg54Rw14HpcKm 6IPy3DEy4aEdCThcojefQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1663573009; x= 1663659409; bh=ivBFTb4mJwy/p2/PscYsL8xWxc9ankAdkoVS7A7AZgY=; b=V qgOQDNLyx6G+k4jCMjLG+kkzWbPc8hKREJi8VuQLvNG0HuqWGCgV89Vi2QG+f23x RGAxowstSWCvsMZBJjbci39Vb8CLfXygESig1chzMLJDpTXOXFzkJ+Ech+73tAJa ZQgyOUMrTKjd2Lhx3puIeDU7odrms/cSwJNx6sYppttBWt4jgVO1lTk7NTkPeas8 nfeRrit8GMvlNN1xs9gltal33m6vVprXF/WY9Ecp2uEj8bXvLyQ2MbkGMCB5nsXx NC0JF2h/UYz37/zTrpeMI5qEmV8XJr8TsemtCtlInXI6N8mU5owsAPf1iPPAaDwr c4yjvzamHIUUrtHJwCSdg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfedviedguddvvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvvefukfhfgggtugfgjgesthhqredttddtudenucfhrhhomhepofgr gihimhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtf frrghtthgvrhhnpeelleefieelleetteefvdeikeeffeffvefhtdevgfehveduveehjedv vdeiledtieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 19 Sep 2022 03:36:47 -0400 (EDT) Date: Mon, 19 Sep 2022 09:36:45 +0200 From: Maxime Ripard To: =?utf-8?B?Sm9zw6kgRXhww7NzaXRv?= Cc: javierm@redhat.com, davidgow@google.com, dlatypov@google.com, tzimmermann@suse.de, 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?B?TWHDrXJh?= Canal Subject: Re: [PATCH v4 3/3] drm/format-helper: Add KUnit tests for drm_fb_xrgb8888_to_gray8() Message-ID: <20220919073645.uf64enluhiwd2b2i@houat> References: <20220919071531.105124-1-jose.exposito89@gmail.com> <20220919071531.105124-4-jose.exposito89@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <20220919071531.105124-4-jose.exposito89@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Mon, Sep 19, 2022 at 09:15:31AM +0200, Jos=E9 Exp=F3sito wrote: > Extend the existing test cases to test the conversion from XRGB8888 to > grayscale. >=20 > Tested-by: Ma=EDra Canal > Reviewed-by: David Gow > Signed-off-by: Jos=E9 Exp=F3sito > --- > .../gpu/drm/tests/drm_format_helper_test.c | 62 +++++++++++++++++++ > 1 file changed, 62 insertions(+) >=20 > diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu= /drm/tests/drm_format_helper_test.c > index 09d358b54da0..71722e828abe 100644 > --- a/drivers/gpu/drm/tests/drm_format_helper_test.c > +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c > @@ -37,6 +37,11 @@ struct convert_to_xrgb2101010_result { > const u32 expected[TEST_BUF_SIZE]; > }; > =20 > +struct convert_to_gray8_result { > + unsigned int dst_pitch; > + const u8 expected[TEST_BUF_SIZE]; > +}; > + > struct convert_xrgb8888_case { > const char *name; > unsigned int pitch; > @@ -46,6 +51,7 @@ struct convert_xrgb8888_case { > struct convert_to_rgb565_result rgb565_result; > struct convert_to_rgb888_result rgb888_result; > struct convert_to_xrgb2101010_result xrgb2101010_result; > + struct convert_to_gray8_result gray8_result; > }; > =20 > static struct convert_xrgb8888_case convert_xrgb8888_cases[] =3D { > @@ -71,6 +77,10 @@ static struct convert_xrgb8888_case convert_xrgb8888_c= ases[] =3D { > .dst_pitch =3D 0, > .expected =3D { 0x3FF00000 }, > }, > + .gray8_result =3D { > + .dst_pitch =3D 0, > + .expected =3D { 0x4C }, > + }, > }, > { > .name =3D "single_pixel_clip_rectangle", > @@ -97,6 +107,10 @@ static struct convert_xrgb8888_case convert_xrgb8888_= cases[] =3D { > .dst_pitch =3D 0, > .expected =3D { 0x3FF00000 }, > }, > + .gray8_result =3D { > + .dst_pitch =3D 0, > + .expected =3D { 0x4C }, > + }, > }, > { > /* Well known colors: White, black, red, green, blue, magenta, > @@ -155,6 +169,15 @@ static struct convert_xrgb8888_case convert_xrgb8888= _cases[] =3D { > 0x3FFFFC00, 0x000FFFFF, > }, > }, > + .gray8_result =3D { > + .dst_pitch =3D 0, > + .expected =3D { > + 0xFF, 0x00, > + 0x4C, 0x99, > + 0x19, 0x66, > + 0xE5, 0xB2, > + }, > + }, > }, > { > /* Randomly picked colors. Full buffer within the clip area. */ > @@ -206,6 +229,14 @@ static struct convert_xrgb8888_case convert_xrgb8888= _cases[] =3D { > 0x2A20300C, 0x1B1705CD, 0x03844672, 0x00000000, 0x00000000, > }, > }, > + .gray8_result =3D { > + .dst_pitch =3D 5, > + .expected =3D { > + 0x3C, 0x33, 0x34, 0x00, 0x00, > + 0x6F, 0x3C, 0x33, 0x00, 0x00, > + 0x34, 0x6F, 0x3C, 0x00, 0x00, > + }, > + }, > }, > }; > =20 > @@ -381,11 +412,42 @@ static void drm_test_fb_xrgb8888_to_xrgb2101010_tes= t(struct kunit *test) > KUNIT_EXPECT_EQ(test, memcmp(buf, result->expected, dst_size), 0); > } > =20 > +static void drm_test_fb_xrgb8888_to_gray8_test(struct kunit *test) > +{ > + const struct convert_xrgb8888_case *params =3D test->param_value; > + const struct convert_to_gray8_result *result =3D ¶ms->gray8_result; > + size_t dst_size; > + __u8 *buf =3D NULL; > + __u32 *xrgb8888 =3D NULL; > + struct iosys_map dst, src; > + > + struct drm_framebuffer fb =3D { > + .format =3D drm_format_info(DRM_FORMAT_XRGB8888), > + .pitches =3D { params->pitch, 0, 0 }, > + }; > + > + dst_size =3D conversion_buf_size(DRM_FORMAT_R8, result->dst_pitch, > + ¶ms->clip); > + KUNIT_ASSERT_GT(test, dst_size, 0); > + > + buf =3D kunit_kzalloc(test, dst_size, GFP_KERNEL); > + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, buf); > + iosys_map_set_vaddr(&dst, buf); > + > + xrgb8888 =3D 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_gray8(&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[] =3D { > KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb332, convert_xrgb8888_gen_p= arams), > KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_rgb565, convert_xrgb8888_gen_p= arams), > 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_xrgb= 8888_gen_params), > + KUNIT_CASE_PARAM(drm_test_fb_xrgb8888_to_gray8_test, convert_xrgb8888_g= en_params), The trailing test feels redundant, and we should order them alphabetically to avoid conflicts as much as possible. Feel free to add my Acked-by: Maxime Ripard And fix this while applying Maxime