From: "Wentland, Harry" <Harry.Wentland@amd.com>
To: "Maíra Canal" <mcanal@igalia.com>,
"Hung, Alex" <Alex.Hung@amd.com>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>
Cc: "wayland-devel@lists.freedesktop.org"
<wayland-devel@lists.freedesktop.org>,
"Liu, Leo" <Leo.Liu@amd.com>,
"ville.syrjala@linux.intel.com" <ville.syrjala@linux.intel.com>,
"pekka.paalanen@collabora.com" <pekka.paalanen@collabora.com>,
"contact@emersion.fr" <contact@emersion.fr>,
"mwen@igalia.com" <mwen@igalia.com>,
"jadahl@redhat.com" <jadahl@redhat.com>,
"sebastian.wick@redhat.com" <sebastian.wick@redhat.com>,
"Sharma, Shashank" <Shashank.Sharma@amd.com>,
"agoins@nvidia.com" <agoins@nvidia.com>,
"joshua@froggi.es" <joshua@froggi.es>,
"mdaenzer@redhat.com" <mdaenzer@redhat.com>,
"aleixpol@kde.org" <aleixpol@kde.org>,
"xaver.hugl@gmail.com" <xaver.hugl@gmail.com>,
"victoria@system76.com" <victoria@system76.com>,
"daniel@ffwll.ch" <daniel@ffwll.ch>,
"uma.shankar@intel.com" <uma.shankar@intel.com>,
"quic_naseer@quicinc.com" <quic_naseer@quicinc.com>,
"quic_cbraga@quicinc.com" <quic_cbraga@quicinc.com>,
"quic_abhinavk@quicinc.com" <quic_abhinavk@quicinc.com>,
"marcan@marcan.st" <marcan@marcan.st>,
"Liviu.Dudau@arm.com" <Liviu.Dudau@arm.com>,
"sashamcintosh@google.com" <sashamcintosh@google.com>,
"chaitanya.kumar.borah@intel.com"
<chaitanya.kumar.borah@intel.com>,
"louis.chauvet@bootlin.com" <louis.chauvet@bootlin.com>,
"arthurgrillo@riseup.net" <arthurgrillo@riseup.net>,
Daniel Stone <daniels@collabora.com>
Subject: Re: [PATCH V10 19/46] drm/tests: Add a few tests around drm_fixed.h
Date: Tue, 17 Jun 2025 14:17:20 +0000 [thread overview]
Message-ID: <c165b6e4-3b78-4961-bd6d-5d13c30c331c@amd.com> (raw)
In-Reply-To: <6bc0883c-beeb-4460-8919-77dbce00ac12@igalia.com>
On 2025-06-17 07:04, Maíra Canal wrote:
> Hi Alex,
>
> On 17/06/25 01:17, Alex Hung wrote:
>> From: Harry Wentland <harry.wentland@amd.com>
>>
>> While working on the CTM implementation of VKMS I had to ascertain
>> myself of a few assumptions. One of those is whether drm_fixed.h
>> treats its numbers using signed-magnitude or twos-complement. It is
>> twos-complement.
>>
>> In order to make someone else's day easier I am adding the
>> drm_test_int2fixp test that validates the above assumption.
>>
>> I am also adding a test for the new sm2fixp function that converts
>> from a signed-magnitude fixed point to the twos-complement fixed
>> point.
>>
>> Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
>> Signed-off-by: Alex Hung <alex.hung@amd.com>
>> Signed-off-by: Harry Wentland <harry.wentland@amd.com>
>> Reviewed-by: Daniel Stone <daniels@collabora.com>
>> ---
>> v7:
>> - Fix checkpatch warnings (Louis Chauvet)
>>
>> v6:
>> - add missing MODULE_DESCRIPTION (Jeff Johnson)
>> - fix buffer overflow
>>
>>
>> drivers/gpu/drm/tests/Makefile | 3 +-
>> drivers/gpu/drm/tests/drm_fixp_test.c | 71 +++++++++++++++++++++++++++
>> 2 files changed, 73 insertions(+), 1 deletion(-)
>> create mode 100644 drivers/gpu/drm/tests/drm_fixp_test.c
>>
>> diff --git a/drivers/gpu/drm/tests/Makefile b/drivers/gpu/drm/tests/
>> Makefile
>> index 3afd6587df08..91437cf34d92 100644
>> --- a/drivers/gpu/drm/tests/Makefile
>> +++ b/drivers/gpu/drm/tests/Makefile
>> @@ -23,6 +23,7 @@ obj-$(CONFIG_DRM_KUNIT_TEST) += \
>> drm_modes_test.o \
>> drm_plane_helper_test.o \
>> drm_probe_helper_test.o \
>> - drm_rect_test.o
>> + drm_rect_test.o \
>> + drm_fixp_test.o
>> CFLAGS_drm_mm_test.o := $(DISABLE_STRUCTLEAK_PLUGIN)
>> diff --git a/drivers/gpu/drm/tests/drm_fixp_test.c b/drivers/gpu/drm/
>> tests/drm_fixp_test.c
>> new file mode 100644
>> index 000000000000..de91177af213
>> --- /dev/null
>> +++ b/drivers/gpu/drm/tests/drm_fixp_test.c
>> @@ -0,0 +1,71 @@
>> +// SPDX-License-Identifier: MIT
>> +/*
>> + * Copyright 2022 Advanced Micro Devices, Inc.
>> + */
>> +
>> +#include <kunit/test.h>
>> +#include <drm/drm_fixed.h>
>> +
>> +static void drm_test_sm2fixp(struct kunit *test)
>> +{
>> + KUNIT_EXPECT_EQ(test, 0x7fffffffffffffffll, ((1ull << 63) - 1));
>> +
>> + /* 1 */
>> + KUNIT_EXPECT_EQ(test, drm_int2fixp(1), drm_sm2fixp(1ull <<
>> DRM_FIXED_POINT));
>> +
>> + /* -1 */
>> + KUNIT_EXPECT_EQ(test, drm_int2fixp(-1),
>> + drm_sm2fixp((1ull << 63) | (1ull << DRM_FIXED_POINT)));
>> +
>> + /* 0.5 */
>> + KUNIT_EXPECT_EQ(test, drm_fixp_from_fraction(1, 2),
>> + drm_sm2fixp(1ull << (DRM_FIXED_POINT - 1)));
>> +
>> + /* -0.5 */
>> + KUNIT_EXPECT_EQ(test, drm_fixp_from_fraction(-1, 2),
>> + drm_sm2fixp((1ull << 63) | (1ull << (DRM_FIXED_POINT -
>> 1))));
>> +}
>> +
>> +static void drm_test_int2fixp(struct kunit *test)
>> +{
>> + /* 1 */
>> + KUNIT_EXPECT_EQ(test, 1ll << 32, drm_int2fixp(1));
>> +
>> + /* -1 */
>> + KUNIT_EXPECT_EQ(test, -(1ll << 32), drm_int2fixp(-1));
>> +
>> + /* 1 + (-1) = 0 */
>> + KUNIT_EXPECT_EQ(test, 0, drm_int2fixp(1) + drm_int2fixp(-1));
>> +
>> + /* 1 / 2 */
>> + KUNIT_EXPECT_EQ(test, 1ll << 31, drm_fixp_from_fraction(1, 2));
>> +
>> + /* -0.5 */
>> + KUNIT_EXPECT_EQ(test, -(1ll << 31), drm_fixp_from_fraction(-1, 2));
>> +
>> + /* (1 / 2) + (-1) = 0.5 */
>> + KUNIT_EXPECT_EQ(test, 1ll << 31, drm_fixp_from_fraction(-1, 2) +
>> drm_int2fixp(1));
>> +
>> + /* (1 / 2) - 1) = 0.5 */
>> + KUNIT_EXPECT_EQ(test, -(1ll << 31), drm_fixp_from_fraction(1, 2)
>> + drm_int2fixp(-1));
>> +
>> + /* (1 / 2) - 1) = 0.5 */
>> + KUNIT_EXPECT_EQ(test, -(1ll << 31), drm_fixp_from_fraction(1, 2)
>> - drm_int2fixp(1));
>> +}
>> +
>> +static struct kunit_case drm_fixp_tests[] = {
>> + KUNIT_CASE(drm_test_int2fixp),
>> + KUNIT_CASE(drm_test_sm2fixp),
>> + { }
>> +};
>> +
>> +static struct kunit_suite drm_rect_test_suite = {
>
> Instead of `drm_rect_test_suite`, how about `drm_fixp_test_suite`?
>
Of course. I forgot to rename it when copy-pasting the
example code.
Thanks.
Harry
>> + .name = "drm_fixp",
>> + .test_cases = drm_fixp_tests,
>> +};
>> +
>> +kunit_test_suite(drm_rect_test_suite);
>> +
>> +MODULE_AUTHOR("AMD");
>> +MODULE_LICENSE("GPL and additional rights");
>
> From the kernel docs, "GPL and additional rights" shouldn't be used in
> new code [1].
>
> [1] https://docs.kernel.org/process/license-rules.html#id1
>
> Best Regards,
> - Maíra
>
>> +MODULE_DESCRIPTION("Unit tests for drm_fixed.h");
>
next prev parent reply other threads:[~2025-06-17 14:17 UTC|newest]
Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-17 4:16 [PATCH V10 00/46] Color Pipeline API w/ VKMS Alex Hung
2025-06-17 4:16 ` [PATCH V10 01/46] drm: Add helper for conversion from signed-magnitude Alex Hung
2025-06-17 4:16 ` [PATCH V10 02/46] drm/vkms: Add kunit tests for VKMS LUT handling Alex Hung
2025-06-17 10:54 ` Maíra Canal
2025-06-17 4:16 ` [PATCH V10 03/46] drm/doc/rfc: Describe why prescriptive color pipeline is needed Alex Hung
2025-06-17 4:16 ` [PATCH V10 04/46] drm/colorop: Introduce new drm_colorop mode object Alex Hung
2025-06-17 4:16 ` [PATCH V10 05/46] drm/colorop: Add TYPE property Alex Hung
2025-06-17 4:16 ` [PATCH V10 06/46] drm/colorop: Add 1D Curve subtype Alex Hung
2025-06-17 4:16 ` [PATCH V10 07/46] drm/colorop: Add BYPASS property Alex Hung
2025-06-17 4:16 ` [PATCH V10 08/46] drm/colorop: Add NEXT property Alex Hung
2025-06-17 4:16 ` [PATCH V10 09/46] drm/colorop: Add atomic state print for drm_colorop Alex Hung
2025-06-17 4:16 ` [PATCH V10 10/46] drm/plane: Add COLOR PIPELINE property Alex Hung
2025-06-17 4:16 ` [PATCH V10 11/46] drm/colorop: Introduce DRM_CLIENT_CAP_PLANE_COLOR_PIPELINE Alex Hung
2025-06-17 4:16 ` [PATCH V10 12/46] Documentation/gpu: document drm_colorop Alex Hung
2025-06-17 4:16 ` [PATCH V10 13/46] drm/colorop: Add destroy functions for color pipeline Alex Hung
2025-07-31 22:11 ` Nícolas F. R. A. Prado
2025-08-03 10:24 ` Simon Ser
2025-06-17 4:16 ` [PATCH V10 14/46] drm/vkms: Add enumerated 1D curve colorop Alex Hung
2025-06-17 4:16 ` [PATCH V10 15/46] drm/vkms: Add kunit tests for linear and sRGB LUTs Alex Hung
2025-06-18 17:59 ` kernel test robot
2025-06-17 4:16 ` [PATCH V10 16/46] drm/colorop: Add 3x4 CTM type Alex Hung
2025-06-17 4:16 ` [PATCH V10 17/46] drm/vkms: Use s32 for internal color pipeline precision Alex Hung
2025-06-17 4:17 ` [PATCH V10 18/46] drm/vkms: add 3x4 matrix in color pipeline Alex Hung
2025-07-30 21:42 ` Nícolas F. R. A. Prado
2025-06-17 4:17 ` [PATCH V10 19/46] drm/tests: Add a few tests around drm_fixed.h Alex Hung
2025-06-17 11:04 ` Maíra Canal
2025-06-17 14:17 ` Wentland, Harry [this message]
2025-06-17 4:17 ` [PATCH V10 20/46] drm/vkms: Add tests for CTM handling Alex Hung
2025-06-17 4:17 ` [PATCH V10 21/46] drm/colorop: pass plane_color_pipeline client cap to atomic check Alex Hung
2025-06-17 4:17 ` [PATCH V10 22/46] drm/colorop: define a new macro for_each_new_colorop_in_state Alex Hung
2025-06-17 4:17 ` [PATCH V10 23/46] drm/amd/display: Ignore deprecated props when plane_color_pipeline set Alex Hung
2025-06-17 4:17 ` [PATCH V10 24/46] drm/amd/display: Add bypass COLOR PIPELINE Alex Hung
2025-06-17 4:17 ` [PATCH V10 25/46] drm/amd/display: Skip color pipeline initialization for cursor plane Alex Hung
2025-06-17 4:17 ` [PATCH V10 26/46] drm/amd/display: Add support for sRGB EOTF in DEGAM block Alex Hung
2025-07-09 19:45 ` Melissa Wen
2025-06-17 4:17 ` [PATCH V10 27/46] drm/amd/display: Add support for sRGB Inverse EOTF in SHAPER block Alex Hung
2025-06-17 4:17 ` [PATCH V10 28/46] drm/amd/display: Add support for sRGB EOTF in BLND block Alex Hung
2025-06-17 4:17 ` [PATCH V10 29/46] drm/colorop: Add PQ 125 EOTF and its inverse Alex Hung
2025-06-17 4:17 ` [PATCH V10 30/46] drm/amd/display: Enable support for PQ 125 EOTF and Inverse Alex Hung
2025-06-17 4:17 ` [PATCH V10 31/46] drm/colorop: add BT2020/BT709 OETF and Inverse OETF Alex Hung
2025-06-17 4:17 ` [PATCH V10 32/46] drm/amd/display: Add support for BT.709 and BT.2020 TFs Alex Hung
2025-06-17 4:17 ` [PATCH V10 33/46] drm: Add Enhanced LUT precision structure Alex Hung
2025-07-08 15:10 ` Simon Ser
2025-07-11 16:28 ` Alex Hung
2025-07-15 4:37 ` Borah, Chaitanya Kumar
2025-07-15 7:44 ` Shankar, Uma
2025-07-15 22:08 ` Alex Hung
2025-07-09 18:49 ` Borah, Chaitanya Kumar
2025-07-11 16:25 ` Alex Hung
2025-06-17 4:17 ` [PATCH V10 34/46] drm/colorop: Add 1D Curve Custom LUT type Alex Hung
2025-06-17 4:17 ` [PATCH V10 35/46] drm/amd/display: add shaper and blend colorops for 1D Curve Custom LUT Alex Hung
2025-06-18 4:41 ` kernel test robot
2025-06-17 4:17 ` [PATCH V10 36/46] drm/amd/display: add 3x4 matrix colorop Alex Hung
2025-06-17 4:17 ` [PATCH V10 37/46] drm/colorop: Add multiplier type Alex Hung
2025-06-17 4:17 ` [PATCH V10 38/46] drm/amd/display: add multiplier colorop Alex Hung
2025-06-17 4:17 ` [PATCH V10 39/46] drm/amd/display: Swap matrix and multiplier Alex Hung
2025-06-17 4:17 ` [PATCH V10 40/46] drm/colorop: Define LUT_1D interpolation Alex Hung
2025-07-09 20:30 ` Simon Ser
2025-08-02 1:49 ` Alex Hung
2025-08-02 1:55 ` Simon Ser
2025-08-04 22:14 ` Xaver Hugl
2025-06-17 4:17 ` [PATCH V10 41/46] drm/colorop: allow non-bypass colorops Alex Hung
2025-07-23 14:00 ` Nícolas F. R. A. Prado
2025-06-17 4:17 ` [PATCH V10 42/46] drm/colorop: Add 3D LUT support to color pipeline Alex Hung
2025-06-17 4:17 ` [PATCH V10 43/46] drm/amd/display: add 3D LUT colorop Alex Hung
2025-08-04 19:51 ` Nícolas F. R. A. Prado
2025-08-12 23:05 ` Alex Hung
2025-06-17 4:17 ` [PATCH V10 44/46] drm/amd/display: Add AMD color pipeline doc Alex Hung
2025-06-17 4:17 ` [PATCH V10 45/46] drm/amd/display: Ensure 3D LUT for color pipeline Alex Hung
2025-07-09 19:56 ` Melissa Wen
2025-08-02 1:59 ` Alex Hung
2025-06-17 4:17 ` [PATCH V10 46/46] drm/amd/display: Disable CRTC degamma when color pipeline is enabled Alex Hung
2025-07-09 19:58 ` Melissa Wen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c165b6e4-3b78-4961-bd6d-5d13c30c331c@amd.com \
--to=harry.wentland@amd.com \
--cc=Alex.Hung@amd.com \
--cc=Leo.Liu@amd.com \
--cc=Liviu.Dudau@arm.com \
--cc=Shashank.Sharma@amd.com \
--cc=agoins@nvidia.com \
--cc=aleixpol@kde.org \
--cc=amd-gfx@lists.freedesktop.org \
--cc=arthurgrillo@riseup.net \
--cc=chaitanya.kumar.borah@intel.com \
--cc=contact@emersion.fr \
--cc=daniel@ffwll.ch \
--cc=daniels@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jadahl@redhat.com \
--cc=joshua@froggi.es \
--cc=louis.chauvet@bootlin.com \
--cc=marcan@marcan.st \
--cc=mcanal@igalia.com \
--cc=mdaenzer@redhat.com \
--cc=mwen@igalia.com \
--cc=pekka.paalanen@collabora.com \
--cc=quic_abhinavk@quicinc.com \
--cc=quic_cbraga@quicinc.com \
--cc=quic_naseer@quicinc.com \
--cc=sashamcintosh@google.com \
--cc=sebastian.wick@redhat.com \
--cc=uma.shankar@intel.com \
--cc=victoria@system76.com \
--cc=ville.syrjala@linux.intel.com \
--cc=wayland-devel@lists.freedesktop.org \
--cc=xaver.hugl@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).