Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3430652lqp; Tue, 26 Mar 2024 08:59:25 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW0ci78zuSlvEe6FBYGhpPB6tLxyGLSWp8Y3nrlfpGhkBd0FOT8AIa/6W70wiBWN1omB+lLARa8AWj+Lon78buju8CLNHL94+wd+WCvIg== X-Google-Smtp-Source: AGHT+IG9aRG1vn5bLQ6dXAjRYGpRjJtuaJ+xeormEXhqkq/XDdqObSgo0vhC6zeeeMidO6++cdUP X-Received: by 2002:a17:907:9727:b0:a47:46d7:a89f with SMTP id jg39-20020a170907972700b00a4746d7a89fmr7329426ejc.30.1711468765146; Tue, 26 Mar 2024 08:59:25 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711468765; cv=pass; d=google.com; s=arc-20160816; b=GdOB6CULOUsAqB8dv1OwU6lycO2mmtU/e141vmOegm4icmHSX6yuSfbzO9FNSd6EKo EzZg0ksu6BW61xHUyKCaM3hJ2vLjOgzThbTyeAQQw2OTioqATRLmEKTE3C0w8kedwjgh 2fHLVjgZj5SPv0rNpru2mnNnzfo29aKc9npnxu+mAxOyYv8HBl0GVRNXUL8bsbh3QCBK EZgaB9IzppHsmi00Owa6uwF7mIf07hxgiJanUjDTo0nZRdLhB9TBDtrJWLvDvJ5dnyEl gbgY0qonvEUcb3WOVyESkCSJ7heDu32vfFlXsa8hQ2WbrVQ/qoXvTvFEI/ex4T7frE2M DbGQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=k5k6zlsPQGeew0PrMggR4KbUmKnw3U9EYAk0N55BMMM=; fh=cwUBeHQ3ezus3RwQuH9AHNS4lDJrjXpRlC9h9x2ursM=; b=PD0OCVQa2giaMvDhCnqxEvfpHleJsMWu5oAMNP8StRnC1CGfCA9cYFMYKV+AVGQuRn lJ/7RRuiyd6SqHSpyjjwxF8kKOUOHEdR7TNKb4mF6Cbp9431k0mkvigDlyP5FUDN+Jus CccYzZTzpn5VA6Q8mDKYV57STm05Un3faCy46WBOZXsgsZ5H8xQ5bGhDxuS2eEZ/G0ye RTUQjW0LbY4X6+sa+QVXQExPQFdqaj8tvcrWY3W3BcyW8tEdoa4c0PtmwbFajOBZ87Hz yNfk2vvVKwlw2zjkxnBiygygJb5KM2+mp3uRJU/vpaRqjxucp0/0/h2BNtAl8aLLYfZV fH/A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=MGeFeauL; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-119408-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119408-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id la16-20020a170907781000b00a4c97c878b8si1394653ejc.710.2024.03.26.08.59.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 08:59:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-119408-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=MGeFeauL; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-119408-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119408-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 598791F810ED for ; Tue, 26 Mar 2024 15:58:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1199313CFB2; Tue, 26 Mar 2024 15:57:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="MGeFeauL" Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A40E13C91F for ; Tue, 26 Mar 2024 15:57:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711468632; cv=none; b=lm6s4CIItdRupwyE0gRb3jU+i6/hQsPRMehF/QrTOzyXdVraJVuEMPhD+BE5Jg9C8Gxv1E50r8wDTHVIOru/siu0q/0PPJ8F5xz0tlk5Q1CtPLGQV20mb/LDnZA7awaVrBzCsl6auw+dMXU1Kz9cd8SUSz5xSp08T+2kRtdlYS8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711468632; c=relaxed/simple; bh=pmnt6tAHD6xRsoOmVgzhbGqnAVWkOvQLKuHpF8EIJzI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=M8kVXmiMDlwdbV1l+NpnyKpjoTtBmxYvgPaBhGzs9rZOjIus09jVW2LybzfnBez7e4IjHdx4pcpThgoLku0J0DfuCWoguvmnMgt9IKVODri4npqUWw1kDQFQzNDJU32AeXFE1hrc4fgYI86tj6MaZdB88c18A9QFjbz50GqZhEo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=MGeFeauL; arc=none smtp.client-ip=217.70.183.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id 1B74EC0002; Tue, 26 Mar 2024 15:57:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1711468627; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=k5k6zlsPQGeew0PrMggR4KbUmKnw3U9EYAk0N55BMMM=; b=MGeFeauLOFKPa/AdbJw+QoRbOsm8jWa8Fphert3dII+l1+D/bMbdDYB9X4EFT7yqLOL6g2 CrML8eWMg7Xx3Dw0dQQJq1gV6ZPh7ZB98OipmWMbTOSbXihsXk8eWHrVkA3ctyUz+p67ch mcH01/YY7oYOBMAv1tmAgWEitX5GGrwV3VB8Yv03ALePFodryowJEHDaqctcS4rg423Jx0 qPrDYheuu2HPuYxh2Zxhx6cLHOvG0mp38ndAKMPYpBlL4ifWG4WNwm1ABkqEjPgtx++iHl Tqoy53/w0Skq3Bs9RFX1wieUNd576kPXVHCusSVqPo5ij8XdNI3q5YJJ/ZUgsg== Date: Tue, 26 Mar 2024 16:57:03 +0100 From: Louis Chauvet To: =?iso-8859-1?Q?Ma=EDra?= Canal Cc: Rodrigo Siqueira , Melissa Wen , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , arthurgrillo@riseup.net, Jonathan Corbet , pekka.paalanen@haloniitty.fi, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, marcheu@google.com, nicolejadeyee@google.com Subject: Re: [PATCH v5 14/16] drm/vkms: Create KUnit tests for YUV conversions Message-ID: Mail-Followup-To: =?iso-8859-1?Q?Ma=EDra?= Canal , Rodrigo Siqueira , Melissa Wen , Haneen Mohammed , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , arthurgrillo@riseup.net, Jonathan Corbet , pekka.paalanen@haloniitty.fi, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, thomas.petazzoni@bootlin.com, seanpaul@google.com, marcheu@google.com, nicolejadeyee@google.com References: <20240313-yuv-v5-0-e610cbd03f52@bootlin.com> <20240313-yuv-v5-14-e610cbd03f52@bootlin.com> <89748cd9-286b-4b07-b96b-5167e4b22cd2@igalia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <89748cd9-286b-4b07-b96b-5167e4b22cd2@igalia.com> X-GND-Sasl: louis.chauvet@bootlin.com Le 25/03/24 - 11:34, Ma?ra Canal a ?crit : > On 3/13/24 14:45, Louis Chauvet wrote: > > From: Arthur Grillo > > > > Create KUnit tests to test the conversion between YUV and RGB. Test each > > conversion and range combination with some common colors. > > > > The code used to compute the expected result can be found in comment. > > > > Signed-off-by: Arthur Grillo > > [Louis Chauvet: > > - fix minor formating issues (whitespace, double line) > > - change expected alpha from 0x0000 to 0xffff > > - adapt to the new get_conversion_matrix usage > > - apply the changes from Arthur > > - move struct pixel_yuv_u8 to the test itself] > > Again, a Co-developed-by tag might be more proper. For this patch, my contribution was very minimal (I only add a call to get_conversion_matrix_to_argb_u16), so I will not add the Co-developed-by. > > Signed-off-by: Louis Chauvet > > --- > > drivers/gpu/drm/vkms/Kconfig | 15 ++ > > drivers/gpu/drm/vkms/Makefile | 1 + > > drivers/gpu/drm/vkms/tests/.kunitconfig | 4 + > > drivers/gpu/drm/vkms/tests/Makefile | 3 + > > drivers/gpu/drm/vkms/tests/vkms_format_test.c | 230 ++++++++++++++++++++++++++ > > drivers/gpu/drm/vkms/vkms_formats.c | 7 +- > > drivers/gpu/drm/vkms/vkms_formats.h | 4 + > > 7 files changed, 262 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/gpu/drm/vkms/Kconfig b/drivers/gpu/drm/vkms/Kconfig > > index b9ecdebecb0b..9b0e1940c14f 100644 > > --- a/drivers/gpu/drm/vkms/Kconfig > > +++ b/drivers/gpu/drm/vkms/Kconfig > > @@ -13,3 +13,18 @@ config DRM_VKMS > > a VKMS. > > > > If M is selected the module will be called vkms. > > + > > +config DRM_VKMS_KUNIT_TESTS > > + tristate "Tests for VKMS" if !KUNIT_ALL_TESTS > > "KUnit tests for VKMS" Fixed in v6. > > + depends on DRM_VKMS && KUNIT > > + default KUNIT_ALL_TESTS > > + help > > + This builds unit tests for VKMS. This option is not useful for > > + distributions or general kernels, but only for kernel > > + developers working on VKMS. > > + > > + For more information on KUnit and unit tests in general, > > + please refer to the KUnit documentation in > > + Documentation/dev-tools/kunit/. > > + > > + If in doubt, say "N". > > \ No newline at end of file > > diff --git a/drivers/gpu/drm/vkms/Makefile b/drivers/gpu/drm/vkms/Makefile > > index 1b28a6a32948..8d3e46dde635 100644 > > --- a/drivers/gpu/drm/vkms/Makefile > > +++ b/drivers/gpu/drm/vkms/Makefile > > @@ -9,3 +9,4 @@ vkms-y := \ > > vkms_writeback.o > > > > obj-$(CONFIG_DRM_VKMS) += vkms.o > > +obj-$(CONFIG_DRM_VKMS_KUNIT_TESTS) += tests/ > > diff --git a/drivers/gpu/drm/vkms/tests/.kunitconfig b/drivers/gpu/drm/vkms/tests/.kunitconfig > > new file mode 100644 > > index 000000000000..70e378228cbd > > --- /dev/null > > +++ b/drivers/gpu/drm/vkms/tests/.kunitconfig > > @@ -0,0 +1,4 @@ > > +CONFIG_KUNIT=y > > +CONFIG_DRM=y > > +CONFIG_DRM_VKMS=y > > +CONFIG_DRM_VKMS_KUNIT_TESTS=y > > diff --git a/drivers/gpu/drm/vkms/tests/Makefile b/drivers/gpu/drm/vkms/tests/Makefile > > new file mode 100644 > > index 000000000000..2d1df668569e > > --- /dev/null > > +++ b/drivers/gpu/drm/vkms/tests/Makefile > > @@ -0,0 +1,3 @@ > > +# SPDX-License-Identifier: GPL-2.0-only > > + > > +obj-$(CONFIG_DRM_VKMS_KUNIT_TESTS) += vkms_format_test.o > > diff --git a/drivers/gpu/drm/vkms/tests/vkms_format_test.c b/drivers/gpu/drm/vkms/tests/vkms_format_test.c > > new file mode 100644 > > index 000000000000..0954d606e44a > > --- /dev/null > > +++ b/drivers/gpu/drm/vkms/tests/vkms_format_test.c [...] > > +/* > > + * The YUV color representation were acquired via the colour python framework. > > + * Below are the function calls used for generating each case. > > + * > > + * for more information got to the docs: > > s/for/For Fixed in v6. > > + * https://colour.readthedocs.io/en/master/generated/colour.RGB_to_YCbCr.html > > + */ > > +static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = { > > + /* > > + * colour.RGB_to_YCbCr(, > > + * K=colour.WEIGHTS_YCBCR["ITU-R BT.601"], > > + * in_bits = 16, > > + * in_legal = False, > > + * in_int = True, > > + * out_bits = 8, > > + * out_legal = False, > > + * out_int = True) > > + */ > > I feel that this Python code is kind of poluting the test cases. This python code is needed to understand where the values come from. I think we should keep it for future reference (add more cases, test yuv 16 bits...) Maybe we can change the array comment to /* * The yuv color representation were acquired via the colour python framework: * * colour.RGB_to_YCbCr(, * K=color.WEIGHTS_YCBCR[""], * [...], * out_legal = ) * * The exact function call arguments are given for each element of this list. * * [...] */ And above each test case: /* * format = "ITU-R BT.601" * out_legal = False */ @Arthur, do you agree with those modifications? > > + { > > + .encoding = DRM_COLOR_YCBCR_BT601, > > + .range = DRM_COLOR_YCBCR_FULL_RANGE, > > + .n_colors = 6, > > + .colors = { > > + { "white", { 0xff, 0x80, 0x80 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, > > + { "gray", { 0x80, 0x80, 0x80 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, > > + { "black", { 0x00, 0x80, 0x80 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, > > + { "red", { 0x4c, 0x55, 0xff }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, > > + { "green", { 0x96, 0x2c, 0x15 }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, > > + { "blue", { 0x1d, 0xff, 0x6b }, { 0xffff, 0x0000, 0x0000, 0xffff }}, > > + }, > > + }, [...] > > diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkms_formats.c > > index edbf4b321b91..863fc91d6d48 100644 > > --- a/drivers/gpu/drm/vkms/vkms_formats.c > > +++ b/drivers/gpu/drm/vkms/vkms_formats.c > > @@ -7,6 +7,8 @@ > > #include > > #include > > > > +#include > > + > > #include "vkms_formats.h" > > > > /** > > @@ -199,8 +201,8 @@ static struct pixel_argb_u16 argb_u16_from_RGB565(const u16 *pixel) > > return out_pixel; > > } > > > > -static struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 cb, u8 cr, > > - struct conversion_matrix *matrix) > > +VISIBLE_IF_KUNIT struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 cb, u8 cr, > > + struct conversion_matrix *matrix) > > { > > u8 r, g, b; > > s64 fp_y, fp_cb, fp_cr; > > @@ -234,6 +236,7 @@ static struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 cb, u8 cr, > > > > return argb_u16_from_u8888(255, r, g, b); > > } > > +EXPORT_SYMBOL_IF_KUNIT(argb_u16_from_yuv888); > > > > /* > > * The following functions are read_line function for each pixel format supported by VKMS. > > diff --git a/drivers/gpu/drm/vkms/vkms_formats.h b/drivers/gpu/drm/vkms/vkms_formats.h > > index e1d324764b17..21e66a0cac16 100644 > > --- a/drivers/gpu/drm/vkms/vkms_formats.h > > +++ b/drivers/gpu/drm/vkms/vkms_formats.h > > @@ -13,4 +13,8 @@ struct conversion_matrix * > > get_conversion_matrix_to_argb_u16(u32 format, enum drm_color_encoding encoding, > > enum drm_color_range range); > > > > +#if IS_ENABLED(CONFIG_KUNIT) > > What about the CONFIG_DRM_EXPORT_FOR_TESTS? As the documentation for CONFIG_DRM_EXPORT_FOR_TESTS don't exists, I don't know what to use. Maybe Arthur knows what to do here? If needed I can apply the modifications for the next iteration. Thanks for all your reviews, Louis Chauvet [...] -- Louis Chauvet, Bootlin Embedded Linux and Kernel engineering https://bootlin.com