drivers/gpu/drm/vkms/tests/vkms_format_test.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/vkms/tests/vkms_format_test.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/vkms/tests/vkms_format_test.c
Extension
.c
Size
10843 bytes
Lines
280
Domain
Driver Families
Bucket
drivers/gpu
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

struct pixel_yuv_u16 {
	u16 y, u, v;
};

/*
 * struct yuv_u16_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_u16_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_u16 yuv;
		struct pixel_argb_u16 argb;
	} colors[TEST_BUFF_SIZE];
};

/*
 * 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:
 * https://colour.readthedocs.io/en/master/generated/colour.RGB_to_YCbCr.html
 */
static struct yuv_u16_to_argb_u16_case yuv_u16_to_argb_u16_cases[] = {
	/*
	 * colour.RGB_to_YCbCr(<rgb color in 16 bit form>,
	 *                     K=colour.WEIGHTS_YCBCR["ITU-R BT.601"],
	 *                     in_bits = 16,
	 *                     in_legal = False,
	 *                     in_int = True,
	 *                     out_bits = 16,
	 *                     out_legal = False,
	 *                     out_int = True)
	 *
	 * Tests cases for color conversion generated by converting RGB
	 * values to YUV BT601 full range using the ITU-R BT.601 weights.
	 */
	{
		.encoding = DRM_COLOR_YCBCR_BT601,
		.range = DRM_COLOR_YCBCR_FULL_RANGE,
		.n_colors = 6,
		.colors = {
			{ "white", { 0xffff, 0x8000, 0x8000 }, { 0xffff, 0xffff, 0xffff, 0xffff }},
			{ "gray",  { 0x8080, 0x8000, 0x8000 }, { 0xffff, 0x8080, 0x8080, 0x8080 }},
			{ "black", { 0x0000, 0x8000, 0x8000 }, { 0xffff, 0x0000, 0x0000, 0x0000 }},
			{ "red",   { 0x4c8b, 0x54ce, 0xffff }, { 0xffff, 0xffff, 0x0000, 0x0000 }},
			{ "green", { 0x9645, 0x2b33, 0x14d1 }, { 0xffff, 0x0000, 0xffff, 0x0000 }},
			{ "blue",  { 0x1d2f, 0xffff, 0x6b2f }, { 0xffff, 0x0000, 0x0000, 0xffff }},
		}
	},
	/*
	 * colour.RGB_to_YCbCr(<rgb color in 16 bit form>,
	 *                     K=colour.WEIGHTS_YCBCR["ITU-R BT.601"],
	 *                     in_bits = 16,
	 *                     in_legal = False,
	 *                     in_int = True,
	 *                     out_bits = 16,
	 *                     out_legal = True,
	 *                     out_int = True)
	 * Tests cases for color conversion generated by converting RGB
	 * values to YUV BT601 limited range using the ITU-R BT.601 weights.
	 */
	{
		.encoding = DRM_COLOR_YCBCR_BT601,
		.range = DRM_COLOR_YCBCR_LIMITED_RANGE,
		.n_colors = 6,
		.colors = {
			{ "white", { 0xeb00, 0x8000, 0x8000 }, { 0xffff, 0xffff, 0xffff, 0xffff }},
			{ "gray",  { 0x7dee, 0x8000, 0x8000 }, { 0xffff, 0x8080, 0x8080, 0x8080 }},
			{ "black", { 0x1000, 0x8000, 0x8000 }, { 0xffff, 0x0000, 0x0000, 0x0000 }},
			{ "red",   { 0x517b, 0x5a34, 0xf000 }, { 0xffff, 0xffff, 0x0000, 0x0000 }},
			{ "green", { 0x908e, 0x35cc, 0x2237 }, { 0xffff, 0x0000, 0xffff, 0x0000 }},
			{ "blue",  { 0x28f7, 0xf000, 0x6dc9 }, { 0xffff, 0x0000, 0x0000, 0xffff }},
		}
	},
	/*
	 * colour.RGB_to_YCbCr(<rgb color in 16 bit form>,
	 *                     K=colour.WEIGHTS_YCBCR["ITU-R BT.709"],

Annotation

Implementation Notes