From nobody Mon Nov 25 01:41:39 2024 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (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 DEB6819E7D0; Thu, 31 Oct 2024 18:06:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730397981; cv=none; b=dD9C6yqfhqdR939fxyp8ARMmwxGXKB2VUGJZ3eWVEBawFrjlkSgL71L09z6PGcuV3B7UlZ9gPWXXms6SWxnkzWEo+soKgpikxT/qnljv/0f+Z8322uSg1LqPg4ol26/+MeYL67nYXqMy0guvPCih0D8HWbbMFxiexR1COgkk35Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730397981; c=relaxed/simple; bh=bKa+5ChJXxkbbGZrOcz2cZ9+0ctUM/r3kl1i6iZsMoA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iv+mDs7NsBnva/GDfX/lRJHQP3hA2yXJJDc5hVITH69fTDF1SyU/aJkKwwRmeeTdFgku8ccju+gRlDi0Ax8G0O9A/G9kwP5npUY+Nmq8L2Xl8TaQUb2UbbZNClPUoHfyla7kNnlEC/PkjEh7nsc5YwyTzcxzZzj5hOV0gL08/d8= 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=j5yo97u/; arc=none smtp.client-ip=217.70.183.200 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="j5yo97u/" Received: by mail.gandi.net (Postfix) with ESMTPSA id 1E6CB2000E; Thu, 31 Oct 2024 18:06:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1730397976; 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=AmhgWt61HTP8ifG1twSSJwLRHokIu6F/ialvnMeQqfQ=; b=j5yo97u/6Vv5Sr6tpyfn4mapIsE/6ikg/oD3JF63w1NePvH64P6ng8Bt9R+CytWkn639SJ ewhbtAbVQwue9iy5Da7uASXRkEpS8IK1mX4gLTwL5rGG1kBUMIU92zx3y/m7JrjAb4gG+f bwVAIinhB2Nh8KQMiYzKSxul8zplaVLKIbj4cFhfPfzR4AR8habZhiGVozm6s34H/0PyP6 qGw2U6VDPqASovDTvVexRMC2QxAofNkr3xM78xIwbGZgn4DyrKYEJQ23HfkUE1/tqZdrWR 8qhzXFu4VQKu1cCMU+NP0Nd7an+Sx/zQ0zzfRQm3Ps6XMtY1qANMgAFmuY7DRA== From: Louis Chauvet Date: Thu, 31 Oct 2024 19:06:05 +0100 Subject: [PATCH v13 5/7] drm/vkms: Create KUnit tests for YUV conversions 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="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241031-yuv-v13-5-c67a337301ae@bootlin.com> References: <20241031-yuv-v13-0-c67a337301ae@bootlin.com> In-Reply-To: <20241031-yuv-v13-0-c67a337301ae@bootlin.com> To: Louis Chauvet , Haneen Mohammed , Simona Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Jonathan Corbet , Rodrigo Siqueira , =?utf-8?q?Ma=C3=ADra_Canal?= , rdunlap@infradead.org, arthurgrillo@riseup.net, pekka.paalanen@haloniitty.fi, Simona Vetter Cc: thomas.petazzoni@bootlin.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com, seanpaul@google.com, marcheu@google.com, nicolejadeyee@google.com, 20241031-yuv-v13-0-bd5463126faa@bootlin.com, Pekka Paalanen X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=15493; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=hHnml+kWAuA0fCqxKFKz0iqBNTn5Q5jlo/NsZD9DAO0=; b=owEBbQKS/ZANAwAIASCtLsZbECziAcsmYgBnI8cOQO9WKE7hmlFdsAMsZT6vruLk1eUkihI8L 6KybjrU+FGJAjMEAAEIAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCZyPHDgAKCRAgrS7GWxAs 4vrvD/9sRdEkLsNNIKMihSFv2SyB6gjTfTcOX9J3BZVeoRl9KFxlHcaEkP6FitvpoNIPBR6IGGk H3wEiqFCcp8CgxqOO7iJF33eo1fajvVL+S9xK2wZFqZgrr7XRVhfKu3X9FDtw8trYDmt8kSbxiV KfmsFJPB8qmhiOaEHp7EuvRdQluQv1LxZpLTpYnyxu/jk1Zf1Z0mlGU+yufugP3RKpBIrUxYPbR AK0s5Nf2675E+1200Unz/JNmQ2ak6aFspibZrSlkhI0+6zz5ZnbgDC3BJHn0Ztp69uWhNsblOQf 9JnBY9QI/TKTcF5YJ78QNRaVJzwSxBQY3hp7zQEaHnY1GQnNC1yZT8bqirmv1s/0jH3HGwvZV/+ jvCP35VvtAwvKIO+sNef3syLdIauSJzWgwhA0w76ou0eoIAK4FjqAMkwqUrFVxLwPYhRsITTFOd 2BmAAWOSAtlaW/lW0FMO5rlpmXv3zroEoNzrvgSge6r+YgIwNNDt1UGYjf8epVhP3G5yLhEugut wlqgPbyijCCgmyKWkeDn7kX469OPnum3MLeJarW0OYc+EedNyGcTLejqLoi7sRlFelfd8X4BVuK jXPxAR2Qt3wPLwqc6C4AQdjtOiqu27s8es85HDZ8tyJSSHJ4PzuG192857msRfoUKwdk1BNcNlE lKAfeh2rwjBayiA== X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 X-GND-Sasl: louis.chauvet@bootlin.com 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. [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] Signed-off-by: Arthur Grillo Acked-by: Pekka Paalanen 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 | 270 ++++++++++++++++++++++= ++++ drivers/gpu/drm/vkms/vkms_formats.c | 7 +- drivers/gpu/drm/vkms/vkms_formats.h | 5 + 7 files changed, 303 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/vkms/Kconfig b/drivers/gpu/drm/vkms/Kconfig index 9def079f685b..d4665e913de7 100644 --- a/drivers/gpu/drm/vkms/Kconfig +++ b/drivers/gpu/drm/vkms/Kconfig @@ -14,3 +14,18 @@ config DRM_VKMS a VKMS. =20 If M is selected the module will be called vkms. + +config DRM_VKMS_KUNIT_TESTS + tristate "KUnit tests for VKMS." if !KUNIT_ALL_TESTS + 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". 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 :=3D \ vkms_writeback.o =20 obj-$(CONFIG_DRM_VKMS) +=3D vkms.o +obj-$(CONFIG_DRM_VKMS_KUNIT_TESTS) +=3D 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=3Dy +CONFIG_DRM=3Dy +CONFIG_DRM_VKMS=3Dy +CONFIG_DRM_VKMS_KUNIT_TESTS=3Dy diff --git a/drivers/gpu/drm/vkms/tests/Makefile b/drivers/gpu/drm/vkms/tes= ts/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) +=3D vkms_format_test.o diff --git a/drivers/gpu/drm/vkms/tests/vkms_format_test.c b/drivers/gpu/dr= m/vkms/tests/vkms_format_test.c new file mode 100644 index 000000000000..4f565ecb591c --- /dev/null +++ b/drivers/gpu/drm/vkms/tests/vkms_format_test.c @@ -0,0 +1,270 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include + +#include +#include + +#include "../../drm_crtc_internal.h" + +#include "../vkms_formats.h" + +#define TEST_BUFF_SIZE 50 + +MODULE_IMPORT_NS(EXPORTED_FOR_KUNIT_TESTING); + +struct pixel_yuv_u8 { + u8 y, u, v; +}; + +/* + * struct yuv_u8_to_argb_u16_case - Reference values to test the color + * conversions in VKMS between YUV to ARGB + * + * @encoding: Encoding used to convert RGB to YUV + * @range: Range used to convert RGB to YUV + * @n_colors: Count of test colors in this case + * @format_pair.name: Name used for this color conversion, used to + * clarify the test results + * @format_pair.rgb: RGB color tested + * @format_pair.yuv: Same color as @format_pair.rgb, but converted to + * YUV using @encoding and @range. + */ +struct yuv_u8_to_argb_u16_case { + enum drm_color_encoding encoding; + enum drm_color_range range; + size_t n_colors; + struct format_pair { + char *name; + struct pixel_yuv_u8 yuv; + struct pixel_argb_u16 argb; + } colors[TEST_BUFF_SIZE]; +}; + +/* + * The YUV color representation were acquired via the colour python framew= ork. + * Below are the function calls used for generating each case. + * + * For more information got to the docs: + * https://colour.readthedocs.io/en/master/generated/colour.RGB_to_YCbCr.h= tml + */ +static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] =3D { + /* + * colour.RGB_to_YCbCr(, + * K=3Dcolour.WEIGHTS_YCBCR["ITU-R BT.601"], + * in_bits =3D 16, + * in_legal =3D False, + * in_int =3D True, + * out_bits =3D 8, + * out_legal =3D False, + * out_int =3D True) + * + * Test cases for conversion between YUV BT601 full range and RGB + * using the ITU-R BT.601 weights. + */ + { + .encoding =3D DRM_COLOR_YCBCR_BT601, + .range =3D DRM_COLOR_YCBCR_FULL_RANGE, + .n_colors =3D 6, + .colors =3D { + { "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 }}, + }, + }, + /* + * colour.RGB_to_YCbCr(, + * K=3Dcolour.WEIGHTS_YCBCR["ITU-R BT.601"], + * in_bits =3D 16, + * in_legal =3D False, + * in_int =3D True, + * out_bits =3D 8, + * out_legal =3D True, + * out_int =3D True) + * Test cases for conversion between YUV BT601 limited range and RGB + * using the ITU-R BT.601 weights. + */ + { + .encoding =3D DRM_COLOR_YCBCR_BT601, + .range =3D DRM_COLOR_YCBCR_LIMITED_RANGE, + .n_colors =3D 6, + .colors =3D { + { "white", { 0xeb, 0x80, 0x80 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, + { "gray", { 0x7e, 0x80, 0x80 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, + { "black", { 0x10, 0x80, 0x80 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, + { "red", { 0x51, 0x5a, 0xf0 }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, + { "green", { 0x91, 0x36, 0x22 }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, + { "blue", { 0x29, 0xf0, 0x6e }, { 0xffff, 0x0000, 0x0000, 0xffff }}, + }, + }, + /* + * colour.RGB_to_YCbCr(, + * K=3Dcolour.WEIGHTS_YCBCR["ITU-R BT.709"], + * in_bits =3D 16, + * in_legal =3D False, + * in_int =3D True, + * out_bits =3D 8, + * out_legal =3D False, + * out_int =3D True) + * Test cases for conversion between YUV BT709 full range and RGB + * using the ITU-R BT.709 weights. + */ + { + .encoding =3D DRM_COLOR_YCBCR_BT709, + .range =3D DRM_COLOR_YCBCR_FULL_RANGE, + .n_colors =3D 4, + .colors =3D { + { "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", { 0x36, 0x63, 0xff }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, + { "green", { 0xb6, 0x1e, 0x0c }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, + { "blue", { 0x12, 0xff, 0x74 }, { 0xffff, 0x0000, 0x0000, 0xffff }}, + }, + }, + /* + * colour.RGB_to_YCbCr(, + * K=3Dcolour.WEIGHTS_YCBCR["ITU-R BT.709"], + * in_bits =3D 16, + * int_legal =3D False, + * in_int =3D True, + * out_bits =3D 8, + * out_legal =3D True, + * out_int =3D True) + * Test cases for conversion between YUV BT709 limited range and RGB + * using the ITU-R BT.709 weights. + */ + { + .encoding =3D DRM_COLOR_YCBCR_BT709, + .range =3D DRM_COLOR_YCBCR_LIMITED_RANGE, + .n_colors =3D 4, + .colors =3D { + { "white", { 0xeb, 0x80, 0x80 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, + { "gray", { 0x7e, 0x80, 0x80 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, + { "black", { 0x10, 0x80, 0x80 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, + { "red", { 0x3f, 0x66, 0xf0 }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, + { "green", { 0xad, 0x2a, 0x1a }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, + { "blue", { 0x20, 0xf0, 0x76 }, { 0xffff, 0x0000, 0x0000, 0xffff }}, + }, + }, + /* + * colour.RGB_to_YCbCr(, + * K=3Dcolour.WEIGHTS_YCBCR["ITU-R BT.2020"], + * in_bits =3D 16, + * in_legal =3D False, + * in_int =3D True, + * out_bits =3D 8, + * out_legal =3D False, + * out_int =3D True) + * Test cases for conversion between YUV BT2020 full range and RGB + * using the ITU-R BT.2020 weights. + */ + { + .encoding =3D DRM_COLOR_YCBCR_BT2020, + .range =3D DRM_COLOR_YCBCR_FULL_RANGE, + .n_colors =3D 4, + .colors =3D { + { "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", { 0x43, 0x5c, 0xff }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, + { "green", { 0xad, 0x24, 0x0b }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, + { "blue", { 0x0f, 0xff, 0x76 }, { 0xffff, 0x0000, 0x0000, 0xffff }}, + }, + }, + /* + * colour.RGB_to_YCbCr(, + * K=3Dcolour.WEIGHTS_YCBCR["ITU-R BT.2020"], + * in_bits =3D 16, + * in_legal =3D False, + * in_int =3D True, + * out_bits =3D 8, + * out_legal =3D True, + * out_int =3D True) + * Test cases for conversion between YUV BT2020 limited range and RGB + * using the ITU-R BT.709 weights. + */ + { + .encoding =3D DRM_COLOR_YCBCR_BT2020, + .range =3D DRM_COLOR_YCBCR_LIMITED_RANGE, + .n_colors =3D 4, + .colors =3D { + { "white", { 0xeb, 0x80, 0x80 }, { 0xffff, 0xffff, 0xffff, 0xffff }}, + { "gray", { 0x7e, 0x80, 0x80 }, { 0xffff, 0x8080, 0x8080, 0x8080 }}, + { "black", { 0x10, 0x80, 0x80 }, { 0xffff, 0x0000, 0x0000, 0x0000 }}, + { "red", { 0x4a, 0x61, 0xf0 }, { 0xffff, 0xffff, 0x0000, 0x0000 }}, + { "green", { 0xa4, 0x2f, 0x19 }, { 0xffff, 0x0000, 0xffff, 0x0000 }}, + { "blue", { 0x1d, 0xf0, 0x77 }, { 0xffff, 0x0000, 0x0000, 0xffff }}, + }, + }, +}; + +/* + * vkms_format_test_yuv_u8_to_argb_u16 - Testing the conversion between YUV + * colors to ARGB colors in VKMS + * + * This test will use the functions get_conversion_matrix_to_argb_u16 and + * argb_u16_from_yuv888 to convert YUV colors (stored in + * yuv_u8_to_argb_u16_cases) into ARGB colors. + * + * As there is a different range between YUV input (8 bits) and RGB output= (16 + * bits), the values are not checked exactly but ensured that they are wit= hin + * the uncertainty range. + */ +static void vkms_format_test_yuv_u8_to_argb_u16(struct kunit *test) +{ + const struct yuv_u8_to_argb_u16_case *param =3D test->param_value; + struct pixel_argb_u16 argb; + + for (size_t i =3D 0; i < param->n_colors; i++) { + const struct format_pair *color =3D ¶m->colors[i]; + struct conversion_matrix matrix; + + get_conversion_matrix_to_argb_u16 + (DRM_FORMAT_NV12, param->encoding, param->range, &matrix); + + argb =3D argb_u16_from_yuv888(color->yuv.y, color->yuv.u, color->yuv.v, = &matrix); + + KUNIT_EXPECT_LE_MSG(test, abs_diff(argb.a, color->argb.a), 257, + "On the A channel of the color %s expected 0x%04x, got 0x%04x", + color->name, color->argb.a, argb.a); + KUNIT_EXPECT_LE_MSG(test, abs_diff(argb.r, color->argb.r), 257, + "On the R channel of the color %s expected 0x%04x, got 0x%04x", + color->name, color->argb.r, argb.r); + KUNIT_EXPECT_LE_MSG(test, abs_diff(argb.g, color->argb.g), 257, + "On the G channel of the color %s expected 0x%04x, got 0x%04x", + color->name, color->argb.g, argb.g); + KUNIT_EXPECT_LE_MSG(test, abs_diff(argb.b, color->argb.b), 257, + "On the B channel of the color %s expected 0x%04x, got 0x%04x", + color->name, color->argb.b, argb.b); + } +} + +static void vkms_format_test_yuv_u8_to_argb_u16_case_desc(struct yuv_u8_to= _argb_u16_case *t, + char *desc) +{ + snprintf(desc, KUNIT_PARAM_DESC_SIZE, "%s - %s", + drm_get_color_encoding_name(t->encoding), drm_get_color_range_name(t->r= ange)); +} + +KUNIT_ARRAY_PARAM(yuv_u8_to_argb_u16, yuv_u8_to_argb_u16_cases, + vkms_format_test_yuv_u8_to_argb_u16_case_desc +); + +static struct kunit_case vkms_format_test_cases[] =3D { + KUNIT_CASE_PARAM(vkms_format_test_yuv_u8_to_argb_u16, yuv_u8_to_argb_u16_= gen_params), + {} +}; + +static struct kunit_suite vkms_format_test_suite =3D { + .name =3D "vkms-format", + .test_cases =3D vkms_format_test_cases, +}; + +kunit_test_suite(vkms_format_test_suite); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("Kunit test for vkms format conversion"); diff --git a/drivers/gpu/drm/vkms/vkms_formats.c b/drivers/gpu/drm/vkms/vkm= s_formats.c index 27865261f384..90adcc924c31 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.c +++ b/drivers/gpu/drm/vkms/vkms_formats.c @@ -7,6 +7,8 @@ #include #include =20 +#include + #include "vkms_formats.h" =20 /** @@ -247,8 +249,8 @@ static struct pixel_argb_u16 argb_u16_from_RGB565(const= __le16 *pixel) return out_pixel; } =20 -static struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 channel_1, u8 c= hannel_2, - const struct conversion_matrix *matrix) +VISIBLE_IF_KUNIT struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 chann= el_1, u8 channel_2, + const struct conversion_matrix *matrix) { u16 r, g, b; s64 fp_y, fp_channel_1, fp_channel_2; @@ -278,6 +280,7 @@ static struct pixel_argb_u16 argb_u16_from_yuv888(u8 y,= u8 channel_1, u8 channel =20 return argb_u16_from_u16161616(0xffff, r, g, b); } +EXPORT_SYMBOL_IF_KUNIT(argb_u16_from_yuv888); =20 /* * The following functions are read_line function for each pixel format su= pported by VKMS. diff --git a/drivers/gpu/drm/vkms/vkms_formats.h b/drivers/gpu/drm/vkms/vkm= s_formats.h index d583855cb320..b4fe62ab9c65 100644 --- a/drivers/gpu/drm/vkms/vkms_formats.h +++ b/drivers/gpu/drm/vkms/vkms_formats.h @@ -13,4 +13,9 @@ void get_conversion_matrix_to_argb_u16(u32 format, enum d= rm_color_encoding encod enum drm_color_range range, struct conversion_matrix *matrix); =20 +#if IS_ENABLED(CONFIG_KUNIT) +struct pixel_argb_u16 argb_u16_from_yuv888(u8 y, u8 channel_1, u8 channel_= 2, + const struct conversion_matrix *matrix); +#endif + #endif /* _VKMS_FORMATS_H_ */ --=20 2.46.2