From patchwork Wed Mar 22 14:06:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Grillo X-Patchwork-Id: 13184128 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 EE542C6FD1F for ; Wed, 22 Mar 2023 14:08:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B7DE910E372; Wed, 22 Mar 2023 14:08:10 +0000 (UTC) Received: from mx1.riseup.net (mx1.riseup.net [198.252.153.129]) by gabe.freedesktop.org (Postfix) with ESMTPS id C55FE10E372 for ; Wed, 22 Mar 2023 14:08:08 +0000 (UTC) Received: from fews2.riseup.net (fews2-pn.riseup.net [10.0.1.84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mail.riseup.net", Issuer "R3" (not verified)) by mx1.riseup.net (Postfix) with ESMTPS id 4PhVgD2CFlzDqtg; Wed, 22 Mar 2023 14:08:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1679494088; bh=QqZ04kQxqtCri+iC38PuLoTkG4/ahUrSurM/vq+14GE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GPZEq2GZ+zLYisxorysCIs8Cmh6rBt07GAgOr5k4RjP+avKwXcufZF8H9etLys0zP HwXYDn9slTumUjOBbsK6zLShp16ht7d8LlVGdtbzTsqiq6qbHgXko9vIzGxCiBGiL+ 6ZeqO4tDMdxM48cIztBpEYN+IH5ELxKoS2cexEXc= X-Riseup-User-ID: 9EB5AF76C62338B51544C52F379EB54F39A5056697C177633B445E6CFFA4149E Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews2.riseup.net (Postfix) with ESMTPSA id 4PhVg66b2qz1y7V; Wed, 22 Mar 2023 14:08:02 +0000 (UTC) From: Arthur Grillo To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/5] drm/tests: Test drm_rect_intersect() Date: Wed, 22 Mar 2023 11:06:57 -0300 Message-Id: <20230322140701.69852-2-arthurgrillo@riseup.net> In-Reply-To: <20230322140701.69852-1-arthurgrillo@riseup.net> References: <20230322140701.69852-1-arthurgrillo@riseup.net> 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: carlos.craveiro@usp.br, tales.aparecida@gmail.com, dlatypov@google.com, javierm@redhat.com, mairacanal@riseup.net, maxime@cerno.tech, andrealmeid@riseup.net, airled@gmail.com, Arthur Grillo , matheus.vieira.g@usp.br Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Insert test for the drm_rect_intersect() function, it also create a helper for comparing drm_rects more easily. Signed-off-by: Arthur Grillo --- drivers/gpu/drm/tests/drm_rect_test.c | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/gpu/drm/tests/drm_rect_test.c b/drivers/gpu/drm/tests/drm_rect_test.c index e9809ea32696..f700984f70a8 100644 --- a/drivers/gpu/drm/tests/drm_rect_test.c +++ b/drivers/gpu/drm/tests/drm_rect_test.c @@ -9,6 +9,15 @@ #include +static void drm_rect_compare(struct kunit *test, const struct drm_rect *r, + const struct drm_rect *expected) +{ + KUNIT_EXPECT_EQ(test, r->x1, expected->x1); + KUNIT_EXPECT_EQ(test, r->y1, expected->y1); + KUNIT_EXPECT_EQ(test, drm_rect_width(r), drm_rect_width(expected)); + KUNIT_EXPECT_EQ(test, drm_rect_height(r), drm_rect_height(expected)); +} + static void drm_test_rect_clip_scaled_div_by_zero(struct kunit *test) { struct drm_rect src, dst, clip; @@ -196,11 +205,32 @@ static void drm_test_rect_clip_scaled_signed_vs_unsigned(struct kunit *test) KUNIT_EXPECT_FALSE_MSG(test, drm_rect_visible(&src), "Source should not be visible\n"); } +static void drm_test_rect_intersect(struct kunit *test) +{ + struct drm_rect r1, r2; + bool visible; + + drm_rect_init(&r1, 0, 0, 2, 2); + drm_rect_init(&r2, 1, 1, 2, 2); + + visible = drm_rect_intersect(&r1, &r2); + + KUNIT_EXPECT_TRUE_MSG(test, visible, "Interserction should be a visible rect"); + drm_rect_compare(test, &r1, &DRM_RECT_INIT(1, 1, 1, 1)); + + drm_rect_init(&r1, 0, 0, 1, 1); + + visible = drm_rect_intersect(&r1, &r2); + + KUNIT_EXPECT_FALSE_MSG(test, visible, "Interserction should not be a visible rect"); +} + static struct kunit_case drm_rect_tests[] = { KUNIT_CASE(drm_test_rect_clip_scaled_div_by_zero), KUNIT_CASE(drm_test_rect_clip_scaled_not_clipped), KUNIT_CASE(drm_test_rect_clip_scaled_clipped), KUNIT_CASE(drm_test_rect_clip_scaled_signed_vs_unsigned), + KUNIT_CASE(drm_test_rect_intersect), { } }; From patchwork Wed Mar 22 14:06:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Grillo X-Patchwork-Id: 13184129 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 8DE00C6FD1C for ; Wed, 22 Mar 2023 14:08:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A279510E38F; Wed, 22 Mar 2023 14:08:17 +0000 (UTC) Received: from mx0.riseup.net (mx0.riseup.net [198.252.153.6]) by gabe.freedesktop.org (Postfix) with ESMTPS id DE0A910E381 for ; Wed, 22 Mar 2023 14:08:14 +0000 (UTC) Received: from fews2.riseup.net (fews2-pn.riseup.net [10.0.1.84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mail.riseup.net", Issuer "R3" (not verified)) by mx0.riseup.net (Postfix) with ESMTPS id 4PhVgL1RgQz9sBV; Wed, 22 Mar 2023 14:08:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1679494094; bh=GHfB5gaxIvtV/NH+pa6/XZydmW0DnzcJHrvmn1kR43o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ACzJZEOWNJk/W+R5slG1kk1OCCn0aW9oN1ngJ1F1eXz4dH0zQ1PuTZcZblP54NBY2 5fbQgwS/ggLuj1om0ZiJqq5DM/iarPXqaYyvjYg50UGwfTFScSPCM3aFpMT2e05lzT 9X4dNWu0opnhof3JMvv9gHgD2J/gghFNyZyqMI8g= X-Riseup-User-ID: 0DEBE64EE1D9BCF099A44936D1938F2ACAF61EE1ED4842B8AD604F42A76D3FAB Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews2.riseup.net (Postfix) with ESMTPSA id 4PhVgD6cRxz1y7V; Wed, 22 Mar 2023 14:08:08 +0000 (UTC) From: Arthur Grillo To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/5] drm/tests: Test drm_rect_calc_hscale() Date: Wed, 22 Mar 2023 11:06:58 -0300 Message-Id: <20230322140701.69852-3-arthurgrillo@riseup.net> In-Reply-To: <20230322140701.69852-1-arthurgrillo@riseup.net> References: <20230322140701.69852-1-arthurgrillo@riseup.net> 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: carlos.craveiro@usp.br, tales.aparecida@gmail.com, dlatypov@google.com, javierm@redhat.com, mairacanal@riseup.net, maxime@cerno.tech, andrealmeid@riseup.net, airled@gmail.com, Arthur Grillo , matheus.vieira.g@usp.br Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Insert test for the drm_rect_hscale() function, besides the test for the usual case it also test for the exceptions. Signed-off-by: Arthur Grillo --- drivers/gpu/drm/tests/drm_rect_test.c | 58 +++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/drivers/gpu/drm/tests/drm_rect_test.c b/drivers/gpu/drm/tests/drm_rect_test.c index f700984f70a8..7e02393092fa 100644 --- a/drivers/gpu/drm/tests/drm_rect_test.c +++ b/drivers/gpu/drm/tests/drm_rect_test.c @@ -9,6 +9,8 @@ #include +#include + static void drm_rect_compare(struct kunit *test, const struct drm_rect *r, const struct drm_rect *expected) { @@ -225,12 +227,68 @@ static void drm_test_rect_intersect(struct kunit *test) KUNIT_EXPECT_FALSE_MSG(test, visible, "Interserction should not be a visible rect"); } +static void drm_test_rect_calc_hscale(struct kunit *test) +{ + struct drm_rect src, dst; + int scaling_factor; + + drm_rect_init(&src, 0, 0, 2, 0); + drm_rect_init(&dst, 0, 0, 1, 0); + + scaling_factor = drm_rect_calc_hscale(&src, &dst, INT_MIN, INT_MAX); + + KUNIT_EXPECT_EQ(test, scaling_factor, 2); +} + +static void drm_test_rect_calc_hscale_out_of_range(struct kunit *test) +{ + struct drm_rect src, dst; + int scaling_factor; + + drm_rect_init(&src, 0, 0, 10, 0); + drm_rect_init(&dst, 0, 0, 1, 0); + + scaling_factor = drm_rect_calc_hscale(&src, &dst, 3, 5); + + KUNIT_EXPECT_EQ(test, scaling_factor, -ERANGE); + + drm_rect_init(&src, 0, 0, 2, 0); + drm_rect_init(&dst, 0, 0, 1, 0); + + scaling_factor = drm_rect_calc_hscale(&src, &dst, 3, 5); + + KUNIT_EXPECT_EQ(test, scaling_factor, -ERANGE); +} + +static void drm_test_rect_calc_hscale_negative_args(struct kunit *test) +{ + struct drm_rect src, dst; + int scaling_factor; + + drm_rect_init(&src, 0, 0, -1, 0); + drm_rect_init(&dst, 0, 0, 1, 0); + + scaling_factor = drm_rect_calc_hscale(&src, &dst, INT_MIN, INT_MAX); + + KUNIT_EXPECT_EQ(test, scaling_factor, -EINVAL); + + drm_rect_init(&src, 0, 0, 1, 0); + drm_rect_init(&dst, 0, 0, -1, 0); + + scaling_factor = drm_rect_calc_hscale(&src, &dst, INT_MIN, INT_MAX); + + KUNIT_EXPECT_EQ(test, scaling_factor, -EINVAL); +} + static struct kunit_case drm_rect_tests[] = { KUNIT_CASE(drm_test_rect_clip_scaled_div_by_zero), KUNIT_CASE(drm_test_rect_clip_scaled_not_clipped), KUNIT_CASE(drm_test_rect_clip_scaled_clipped), KUNIT_CASE(drm_test_rect_clip_scaled_signed_vs_unsigned), KUNIT_CASE(drm_test_rect_intersect), + KUNIT_CASE(drm_test_rect_calc_hscale), + KUNIT_CASE(drm_test_rect_calc_hscale_out_of_range), + KUNIT_CASE(drm_test_rect_calc_hscale_negative_args), { } }; From patchwork Wed Mar 22 14:06:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Grillo X-Patchwork-Id: 13184130 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 A7CAEC6FD1C for ; Wed, 22 Mar 2023 14:08:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D3C1C10E381; Wed, 22 Mar 2023 14:08:21 +0000 (UTC) Received: from mx0.riseup.net (mx0.riseup.net [198.252.153.6]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9352010E381 for ; Wed, 22 Mar 2023 14:08:19 +0000 (UTC) Received: from fews2.riseup.net (fews2-pn.riseup.net [10.0.1.84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mail.riseup.net", Issuer "R3" (not verified)) by mx0.riseup.net (Postfix) with ESMTPS id 4PhVgR0rNrz9sBV; Wed, 22 Mar 2023 14:08:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1679494099; bh=o1VzzB+7NsRXn5kW8WzT8SolqVYPi/O66203uaj/U5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d6WiuMwYNbBvyKCjPqxqa/MkNdlf1IkORhEDfWJfia4s2e0cbvNphJ7Vid9tEBmHu rM87d7Oi0LqDWTwfNM2kjKXLd05VpP7wSaBiXh9f/jlJbw2aYzWtgnqMk7O+0dWQAO dkaBarPMwKWXj3BvcNnIgHb2iInMNX5WQ2F0GV+I= X-Riseup-User-ID: F1C1B79971C97704F76C95666C97F3C78B7703904497D358FAB77072EE517C47 Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews2.riseup.net (Postfix) with ESMTPSA id 4PhVgL679fz1y7V; Wed, 22 Mar 2023 14:08:14 +0000 (UTC) From: Arthur Grillo To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/5] drm/tests: Test drm_rect_calc_vscale() Date: Wed, 22 Mar 2023 11:06:59 -0300 Message-Id: <20230322140701.69852-4-arthurgrillo@riseup.net> In-Reply-To: <20230322140701.69852-1-arthurgrillo@riseup.net> References: <20230322140701.69852-1-arthurgrillo@riseup.net> 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: carlos.craveiro@usp.br, tales.aparecida@gmail.com, dlatypov@google.com, javierm@redhat.com, mairacanal@riseup.net, maxime@cerno.tech, andrealmeid@riseup.net, airled@gmail.com, Arthur Grillo , matheus.vieira.g@usp.br Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Insert test for the drm_rect_vscale() function, besides the test for the usual case it also test for the exceptions. Signed-off-by: Arthur Grillo --- drivers/gpu/drm/tests/drm_rect_test.c | 56 +++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/drivers/gpu/drm/tests/drm_rect_test.c b/drivers/gpu/drm/tests/drm_rect_test.c index 7e02393092fa..0f7736073390 100644 --- a/drivers/gpu/drm/tests/drm_rect_test.c +++ b/drivers/gpu/drm/tests/drm_rect_test.c @@ -280,6 +280,59 @@ static void drm_test_rect_calc_hscale_negative_args(struct kunit *test) KUNIT_EXPECT_EQ(test, scaling_factor, -EINVAL); } +static void drm_test_rect_calc_vscale(struct kunit *test) +{ + struct drm_rect src, dst; + int scaling_factor; + + drm_rect_init(&src, 0, 0, 0, 2); + drm_rect_init(&dst, 0, 0, 0, 1); + + scaling_factor = drm_rect_calc_vscale(&src, &dst, INT_MIN, INT_MAX); + + KUNIT_EXPECT_EQ(test, scaling_factor, 2); +} + +static void drm_test_rect_calc_vscale_out_of_range(struct kunit *test) +{ + struct drm_rect src, dst; + int scaling_factor; + + drm_rect_init(&src, 0, 0, 0, 10); + drm_rect_init(&dst, 0, 0, 0, 1); + + scaling_factor = drm_rect_calc_vscale(&src, &dst, 3, 5); + + KUNIT_EXPECT_EQ(test, scaling_factor, -ERANGE); + + drm_rect_init(&src, 0, 0, 0, 2); + drm_rect_init(&dst, 0, 0, 0, 1); + + scaling_factor = drm_rect_calc_vscale(&src, &dst, 3, 5); + + KUNIT_EXPECT_EQ(test, scaling_factor, -ERANGE); +} + +static void drm_test_rect_calc_vscale_negative_args(struct kunit *test) +{ + struct drm_rect src, dst; + int scaling_factor; + + drm_rect_init(&src, 0, 0, 0, -1); + drm_rect_init(&dst, 0, 0, 0, 1); + + scaling_factor = drm_rect_calc_vscale(&src, &dst, INT_MIN, INT_MAX); + + KUNIT_EXPECT_EQ(test, scaling_factor, -EINVAL); + + drm_rect_init(&src, 0, 0, 0, 1); + drm_rect_init(&dst, 0, 0, 0, -1); + + scaling_factor = drm_rect_calc_vscale(&src, &dst, INT_MIN, INT_MAX); + + KUNIT_EXPECT_EQ(test, scaling_factor, -EINVAL); +} + static struct kunit_case drm_rect_tests[] = { KUNIT_CASE(drm_test_rect_clip_scaled_div_by_zero), KUNIT_CASE(drm_test_rect_clip_scaled_not_clipped), @@ -289,6 +342,9 @@ static struct kunit_case drm_rect_tests[] = { KUNIT_CASE(drm_test_rect_calc_hscale), KUNIT_CASE(drm_test_rect_calc_hscale_out_of_range), KUNIT_CASE(drm_test_rect_calc_hscale_negative_args), + KUNIT_CASE(drm_test_rect_calc_vscale), + KUNIT_CASE(drm_test_rect_calc_vscale_out_of_range), + KUNIT_CASE(drm_test_rect_calc_vscale_negative_args), { } }; From patchwork Wed Mar 22 14:07:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Grillo X-Patchwork-Id: 13184131 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 A3687C6FD1C for ; Wed, 22 Mar 2023 14:08:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F284810E3BF; Wed, 22 Mar 2023 14:08:26 +0000 (UTC) Received: from mx0.riseup.net (mx0.riseup.net [198.252.153.6]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9D7D310E3BF for ; Wed, 22 Mar 2023 14:08:25 +0000 (UTC) Received: from fews2.riseup.net (fews2-pn.riseup.net [10.0.1.84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mail.riseup.net", Issuer "R3" (not verified)) by mx0.riseup.net (Postfix) with ESMTPS id 4PhVgY0gJRz9tDb; Wed, 22 Mar 2023 14:08:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1679494105; bh=K6CujEfcNUcCD9c8fWE3PQia5ltQ4OFqpq7w8AsLfA0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DuzFjmvB1/J9MK7Bmi7T5fmg7UUsDVxx/e4YPxYKWQZXv1r4r9U4+DQJSIjWkb4XB 7WGq4CCecDQ1lgxs+NoLFNRq90cuyfH5HL6z1jmaZ/wdaHQaRBX1rZK2LrGqHjvSqi RPabjy6AZ+oiaYGhH6/uZhWHJT1p/WGAdxK5Zi7s= X-Riseup-User-ID: D92E7C4D4B9505C2F3350BDA29ACB68D2CDB3503F23E0A4171E1C782DD6BFECB Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews2.riseup.net (Postfix) with ESMTPSA id 4PhVgR5Tpcz1y7V; Wed, 22 Mar 2023 14:08:19 +0000 (UTC) From: Arthur Grillo To: dri-devel@lists.freedesktop.org Subject: [PATCH 4/5] drm/tests: Test drm_rect_rotate() Date: Wed, 22 Mar 2023 11:07:00 -0300 Message-Id: <20230322140701.69852-5-arthurgrillo@riseup.net> In-Reply-To: <20230322140701.69852-1-arthurgrillo@riseup.net> References: <20230322140701.69852-1-arthurgrillo@riseup.net> 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: carlos.craveiro@usp.br, tales.aparecida@gmail.com, dlatypov@google.com, javierm@redhat.com, mairacanal@riseup.net, maxime@cerno.tech, andrealmeid@riseup.net, airled@gmail.com, Arthur Grillo , matheus.vieira.g@usp.br Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Insert test for the drm_rect_rotate() function, create test cases for all the rotation modes. Signed-off-by: Arthur Grillo --- drivers/gpu/drm/tests/drm_rect_test.c | 74 +++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/drivers/gpu/drm/tests/drm_rect_test.c b/drivers/gpu/drm/tests/drm_rect_test.c index 0f7736073390..46139e796f3f 100644 --- a/drivers/gpu/drm/tests/drm_rect_test.c +++ b/drivers/gpu/drm/tests/drm_rect_test.c @@ -8,6 +8,7 @@ #include #include +#include #include @@ -333,6 +334,78 @@ static void drm_test_rect_calc_vscale_negative_args(struct kunit *test) KUNIT_EXPECT_EQ(test, scaling_factor, -EINVAL); } +struct drm_rect_rotate_case { + const char *name; + unsigned int rotation; + struct drm_rect rect; + int width, height; + struct drm_rect expected; +}; + +static const struct drm_rect_rotate_case drm_rect_rotate_cases[] = { + { + .name = "reflect x", + .rotation = DRM_MODE_REFLECT_X, + .rect = DRM_RECT_INIT(0, 0, 5, 5), + .width = 0, .height = 0, + .expected = DRM_RECT_INIT(-5, 0, 5, 5), + }, + { + .name = "reflect y", + .rotation = DRM_MODE_REFLECT_Y, + .rect = DRM_RECT_INIT(0, 0, 5, 5), + .width = 0, .height = 0, + .expected = DRM_RECT_INIT(0, -5, 5, 5), + }, + { + .name = "rotate 0", + .rotation = DRM_MODE_ROTATE_0, + .rect = DRM_RECT_INIT(0, 0, 5, 5), + .width = 0, .height = 0, + .expected = DRM_RECT_INIT(0, 0, 5, 5), + }, + { + .name = "rotate 90", + .rotation = DRM_MODE_ROTATE_90, + .rect = DRM_RECT_INIT(0, 0, 5, 10), + .width = 0, .height = 0, + .expected = DRM_RECT_INIT(0, -5, 10, 5), + }, + { + .name = "rotate 180", + .rotation = DRM_MODE_ROTATE_180, + .rect = DRM_RECT_INIT(0, 0, 5, 10), + .width = 0, .height = 0, + .expected = DRM_RECT_INIT(-5, -10, 5, 10), + }, + { + .name = "rotate 270", + .rotation = DRM_MODE_ROTATE_270, + .rect = DRM_RECT_INIT(0, 0, 5, 10), + .width = 0, .height = 0, + .expected = DRM_RECT_INIT(-10, 0, 10, 5), + }, +}; + +static void drm_rect_case_desc(const struct drm_rect_rotate_case *t, char *desc) +{ + strscpy(desc, t->name, KUNIT_PARAM_DESC_SIZE); +} + +KUNIT_ARRAY_PARAM(drm_rect_rotate, drm_rect_rotate_cases, drm_rect_case_desc); + +static void drm_test_rect_rotate(struct kunit *test) +{ + const struct drm_rect_rotate_case *params = test->param_value; + struct drm_rect r; + + memcpy(&r, ¶ms->rect, sizeof(struct drm_rect)); + + drm_rect_rotate(&r, params->width, params->height, params->rotation); + + drm_rect_compare(test, &r, ¶ms->expected); +} + static struct kunit_case drm_rect_tests[] = { KUNIT_CASE(drm_test_rect_clip_scaled_div_by_zero), KUNIT_CASE(drm_test_rect_clip_scaled_not_clipped), @@ -345,6 +418,7 @@ static struct kunit_case drm_rect_tests[] = { KUNIT_CASE(drm_test_rect_calc_vscale), KUNIT_CASE(drm_test_rect_calc_vscale_out_of_range), KUNIT_CASE(drm_test_rect_calc_vscale_negative_args), + KUNIT_CASE_PARAM(drm_test_rect_rotate, drm_rect_rotate_gen_params), { } }; From patchwork Wed Mar 22 14:07:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Grillo X-Patchwork-Id: 13184133 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 5056AC6FD1C for ; Wed, 22 Mar 2023 14:08:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id AFE4A10E950; Wed, 22 Mar 2023 14:08:37 +0000 (UTC) Received: from mx0.riseup.net (mx0.riseup.net [198.252.153.6]) by gabe.freedesktop.org (Postfix) with ESMTPS id 025A010E94F for ; Wed, 22 Mar 2023 14:08:31 +0000 (UTC) Received: from fews2.riseup.net (fews2-pn.riseup.net [10.0.1.84]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mail.riseup.net", Issuer "R3" (not verified)) by mx0.riseup.net (Postfix) with ESMTPS id 4PhVgf43jdz9tDb; Wed, 22 Mar 2023 14:08:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1679494110; bh=elqKTR7jJqaJa01DazVec6DGI5ZIrg7ojrmzkI353aM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CVaElt4asOXs+D3CbmY6/5tDjE8rIt7t0Z+4YHmGFBNpbbcURdtJ4uANM683UH9Qc x7Jf7f+o0opz+eNdB6AnqXYVxisDAJsiiKAQYWJ+DGmZuB+ggXqqVqY/hfoHd3vW/y o5YRslGhxKQGC1YRMI+LfA/CcIdGzAeRKmaZEuVc= X-Riseup-User-ID: 6A4CE56EAB94217BC65140A2AF257B6C91529CE0614EF07DC3829661217CA346 Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews2.riseup.net (Postfix) with ESMTPSA id 4PhVgY4KMWz1y7V; Wed, 22 Mar 2023 14:08:25 +0000 (UTC) From: Arthur Grillo To: dri-devel@lists.freedesktop.org Subject: [PATCH 5/5] drm/test: Test drm_rect_rotate_inv() Date: Wed, 22 Mar 2023 11:07:01 -0300 Message-Id: <20230322140701.69852-6-arthurgrillo@riseup.net> In-Reply-To: <20230322140701.69852-1-arthurgrillo@riseup.net> References: <20230322140701.69852-1-arthurgrillo@riseup.net> 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: carlos.craveiro@usp.br, tales.aparecida@gmail.com, dlatypov@google.com, javierm@redhat.com, mairacanal@riseup.net, maxime@cerno.tech, andrealmeid@riseup.net, airled@gmail.com, Arthur Grillo , matheus.vieira.g@usp.br Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Insert test for the drm_rect_rotate_inv() function, by expanding the existing test framework for the drm_rect_rotate(). Signed-off-by: Arthur Grillo --- drivers/gpu/drm/tests/drm_rect_test.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/gpu/drm/tests/drm_rect_test.c b/drivers/gpu/drm/tests/drm_rect_test.c index 46139e796f3f..6d41c0a3cae0 100644 --- a/drivers/gpu/drm/tests/drm_rect_test.c +++ b/drivers/gpu/drm/tests/drm_rect_test.c @@ -406,6 +406,18 @@ static void drm_test_rect_rotate(struct kunit *test) drm_rect_compare(test, &r, ¶ms->expected); } +static void drm_test_rect_rotate_inv(struct kunit *test) +{ + const struct drm_rect_rotate_case *params = test->param_value; + struct drm_rect r; + + memcpy(&r, ¶ms->expected, sizeof(struct drm_rect)); + + drm_rect_rotate_inv(&r, params->width, params->height, params->rotation); + + drm_rect_compare(test, &r, ¶ms->rect); +} + static struct kunit_case drm_rect_tests[] = { KUNIT_CASE(drm_test_rect_clip_scaled_div_by_zero), KUNIT_CASE(drm_test_rect_clip_scaled_not_clipped), @@ -419,6 +431,7 @@ static struct kunit_case drm_rect_tests[] = { KUNIT_CASE(drm_test_rect_calc_vscale_out_of_range), KUNIT_CASE(drm_test_rect_calc_vscale_negative_args), KUNIT_CASE_PARAM(drm_test_rect_rotate, drm_rect_rotate_gen_params), + KUNIT_CASE_PARAM(drm_test_rect_rotate_inv, drm_rect_rotate_gen_params), { } };