1414MODULE_IMPORT_NS ("EXPORTED_FOR_KUNIT_TESTING" );
1515
1616/**
17- * struct pixel_yuv_u8 - Internal representation of a pixel color.
18- * @y: Luma value, stored in 8 bits, without padding, using
17+ * struct pixel_yuv_u16 - Internal representation of a pixel color.
18+ * @y: Luma value, stored in 16 bits, without padding, using
1919 * machine endianness
20- * @u: Blue difference chroma value, stored in 8 bits, without padding, using
20+ * @u: Blue difference chroma value, stored in 16 bits, without padding, using
2121 * machine endianness
22- * @v: Red difference chroma value, stored in 8 bits, without padding, using
22+ * @v: Red difference chroma value, stored in 16 bits, without padding, using
2323 * machine endianness
2424 */
25- struct pixel_yuv_u8 {
26- u8 y , u , v ;
25+ struct pixel_yuv_u16 {
26+ u16 y , u , v ;
2727};
2828
2929/*
30- * struct yuv_u8_to_argb_u16_case - Reference values to test the color
30+ * struct yuv_u16_to_argb_u16_case - Reference values to test the color
3131 * conversions in VKMS between YUV to ARGB
3232 *
3333 * @encoding: Encoding used to convert RGB to YUV
@@ -39,13 +39,13 @@ struct pixel_yuv_u8 {
3939 * @format_pair.yuv: Same color as @format_pair.rgb, but converted to
4040 * YUV using @encoding and @range.
4141 */
42- struct yuv_u8_to_argb_u16_case {
42+ struct yuv_u16_to_argb_u16_case {
4343 enum drm_color_encoding encoding ;
4444 enum drm_color_range range ;
4545 size_t n_colors ;
4646 struct format_pair {
4747 char * name ;
48- struct pixel_yuv_u8 yuv ;
48+ struct pixel_yuv_u16 yuv ;
4949 struct pixel_argb_u16 argb ;
5050 } colors [TEST_BUFF_SIZE ];
5151};
@@ -57,14 +57,14 @@ struct yuv_u8_to_argb_u16_case {
5757 * For more information got to the docs:
5858 * https://colour.readthedocs.io/en/master/generated/colour.RGB_to_YCbCr.html
5959 */
60- static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases [] = {
60+ static struct yuv_u16_to_argb_u16_case yuv_u16_to_argb_u16_cases [] = {
6161 /*
6262 * colour.RGB_to_YCbCr(<rgb color in 16 bit form>,
6363 * K=colour.WEIGHTS_YCBCR["ITU-R BT.601"],
6464 * in_bits = 16,
6565 * in_legal = False,
6666 * in_int = True,
67- * out_bits = 8 ,
67+ * out_bits = 16 ,
6868 * out_legal = False,
6969 * out_int = True)
7070 *
@@ -76,21 +76,21 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = {
7676 .range = DRM_COLOR_YCBCR_FULL_RANGE ,
7777 .n_colors = 6 ,
7878 .colors = {
79- { "white" , { 0xff , 0x80 , 0x80 }, { 0xffff , 0xffff , 0xffff , 0xffff }},
80- { "gray" , { 0x80 , 0x80 , 0x80 }, { 0xffff , 0x8080 , 0x8080 , 0x8080 }},
81- { "black" , { 0x00 , 0x80 , 0x80 }, { 0xffff , 0x0000 , 0x0000 , 0x0000 }},
82- { "red" , { 0x4c , 0x55 , 0xff }, { 0xffff , 0xffff , 0x0000 , 0x0000 }},
83- { "green" , { 0x96 , 0x2c , 0x15 }, { 0xffff , 0x0000 , 0xffff , 0x0000 }},
84- { "blue" , { 0x1d , 0xff , 0x6b }, { 0xffff , 0x0000 , 0x0000 , 0xffff }},
85- },
79+ { "white" , { 0xffff , 0x8000 , 0x8000 }, { 0xffff , 0xffff , 0xffff , 0xffff }},
80+ { "gray" , { 0x8080 , 0x8000 , 0x8000 }, { 0xffff , 0x8080 , 0x8080 , 0x8080 }},
81+ { "black" , { 0x0000 , 0x8000 , 0x8000 }, { 0xffff , 0x0000 , 0x0000 , 0x0000 }},
82+ { "red" , { 0x4c8b , 0x54ce , 0xffff }, { 0xffff , 0xffff , 0x0000 , 0x0000 }},
83+ { "green" , { 0x9645 , 0x2b33 , 0x14d1 }, { 0xffff , 0x0000 , 0xffff , 0x0000 }},
84+ { "blue" , { 0x1d2f , 0xffff , 0x6b2f }, { 0xffff , 0x0000 , 0x0000 , 0xffff }},
85+ }
8686 },
8787 /*
8888 * colour.RGB_to_YCbCr(<rgb color in 16 bit form>,
8989 * K=colour.WEIGHTS_YCBCR["ITU-R BT.601"],
9090 * in_bits = 16,
9191 * in_legal = False,
9292 * in_int = True,
93- * out_bits = 8 ,
93+ * out_bits = 16 ,
9494 * out_legal = True,
9595 * out_int = True)
9696 * Tests cases for color conversion generated by converting RGB
@@ -101,21 +101,21 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = {
101101 .range = DRM_COLOR_YCBCR_LIMITED_RANGE ,
102102 .n_colors = 6 ,
103103 .colors = {
104- { "white" , { 0xeb , 0x80 , 0x80 }, { 0xffff , 0xffff , 0xffff , 0xffff }},
105- { "gray" , { 0x7e , 0x80 , 0x80 }, { 0xffff , 0x8080 , 0x8080 , 0x8080 }},
106- { "black" , { 0x10 , 0x80 , 0x80 }, { 0xffff , 0x0000 , 0x0000 , 0x0000 }},
107- { "red" , { 0x51 , 0x5a , 0xf0 }, { 0xffff , 0xffff , 0x0000 , 0x0000 }},
108- { "green" , { 0x91 , 0x36 , 0x22 }, { 0xffff , 0x0000 , 0xffff , 0x0000 }},
109- { "blue" , { 0x29 , 0xf0 , 0x6e }, { 0xffff , 0x0000 , 0x0000 , 0xffff }},
110- },
104+ { "white" , { 0xeb00 , 0x8000 , 0x8000 }, { 0xffff , 0xffff , 0xffff , 0xffff }},
105+ { "gray" , { 0x7dee , 0x8000 , 0x8000 }, { 0xffff , 0x8080 , 0x8080 , 0x8080 }},
106+ { "black" , { 0x1000 , 0x8000 , 0x8000 }, { 0xffff , 0x0000 , 0x0000 , 0x0000 }},
107+ { "red" , { 0x517b , 0x5a34 , 0xf000 }, { 0xffff , 0xffff , 0x0000 , 0x0000 }},
108+ { "green" , { 0x908e , 0x35cc , 0x2237 }, { 0xffff , 0x0000 , 0xffff , 0x0000 }},
109+ { "blue" , { 0x28f7 , 0xf000 , 0x6dc9 }, { 0xffff , 0x0000 , 0x0000 , 0xffff }},
110+ }
111111 },
112112 /*
113113 * colour.RGB_to_YCbCr(<rgb color in 16 bit form>,
114114 * K=colour.WEIGHTS_YCBCR["ITU-R BT.709"],
115115 * in_bits = 16,
116116 * in_legal = False,
117117 * in_int = True,
118- * out_bits = 8 ,
118+ * out_bits = 16 ,
119119 * out_legal = False,
120120 * out_int = True)
121121 * Tests cases for color conversion generated by converting RGB
@@ -126,21 +126,21 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = {
126126 .range = DRM_COLOR_YCBCR_FULL_RANGE ,
127127 .n_colors = 6 ,
128128 .colors = {
129- { "white" , { 0xff , 0x80 , 0x80 }, { 0xffff , 0xffff , 0xffff , 0xffff }},
130- { "gray" , { 0x80 , 0x80 , 0x80 }, { 0xffff , 0x8080 , 0x8080 , 0x8080 }},
131- { "black" , { 0x00 , 0x80 , 0x80 }, { 0xffff , 0x0000 , 0x0000 , 0x0000 }},
132- { "red" , { 0x36 , 0x63 , 0xff }, { 0xffff , 0xffff , 0x0000 , 0x0000 }},
133- { "green" , { 0xb6 , 0x1e , 0x0c }, { 0xffff , 0x0000 , 0xffff , 0x0000 }},
134- { "blue" , { 0x12 , 0xff , 0x74 }, { 0xffff , 0x0000 , 0x0000 , 0xffff }},
135- },
129+ { "white" , { 0xffff , 0x8000 , 0x8000 }, { 0xffff , 0xffff , 0xffff , 0xffff }},
130+ { "gray" , { 0x8080 , 0x8000 , 0x8000 }, { 0xffff , 0x8080 , 0x8080 , 0x8080 }},
131+ { "black" , { 0x0000 , 0x8000 , 0x8000 }, { 0xffff , 0x0000 , 0x0000 , 0x0000 }},
132+ { "red" , { 0x366d , 0x62ac , 0xffff }, { 0xffff , 0xffff , 0x0000 , 0x0000 }},
133+ { "green" , { 0xb717 , 0x1d55 , 0x0bbd }, { 0xffff , 0x0000 , 0xffff , 0x0000 }},
134+ { "blue" , { 0x127c , 0xffff , 0x7443 }, { 0xffff , 0x0000 , 0x0000 , 0xffff }},
135+ }
136136 },
137137 /*
138138 * colour.RGB_to_YCbCr(<rgb color in 16 bit form>,
139139 * K=colour.WEIGHTS_YCBCR["ITU-R BT.709"],
140140 * in_bits = 16,
141- * int_legal = False,
141+ * in_legal = False,
142142 * in_int = True,
143- * out_bits = 8 ,
143+ * out_bits = 16 ,
144144 * out_legal = True,
145145 * out_int = True)
146146 * Tests cases for color conversion generated by converting RGB
@@ -151,21 +151,21 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = {
151151 .range = DRM_COLOR_YCBCR_LIMITED_RANGE ,
152152 .n_colors = 6 ,
153153 .colors = {
154- { "white" , { 0xeb , 0x80 , 0x80 }, { 0xffff , 0xffff , 0xffff , 0xffff }},
155- { "gray" , { 0x7e , 0x80 , 0x80 }, { 0xffff , 0x8080 , 0x8080 , 0x8080 }},
156- { "black" , { 0x10 , 0x80 , 0x80 }, { 0xffff , 0x0000 , 0x0000 , 0x0000 }},
157- { "red" , { 0x3f , 0x66 , 0xf0 }, { 0xffff , 0xffff , 0x0000 , 0x0000 }},
158- { "green" , { 0xad , 0x2a , 0x1a }, { 0xffff , 0x0000 , 0xffff , 0x0000 }},
159- { "blue" , { 0x20 , 0xf0 , 0x76 }, { 0xffff , 0x0000 , 0x0000 , 0xffff }},
160- },
154+ { "white" , { 0xeb00 , 0x8000 , 0x8000 }, { 0xffff , 0xffff , 0xffff , 0xffff }},
155+ { "gray" , { 0x7dee , 0x8000 , 0x8000 }, { 0xffff , 0x8080 , 0x8080 , 0x8080 }},
156+ { "black" , { 0x1000 , 0x8000 , 0x8000 }, { 0xffff , 0x0000 , 0x0000 , 0x0000 }},
157+ { "red" , { 0x3e8f , 0x6656 , 0xf000 }, { 0xffff , 0xffff , 0x0000 , 0x0000 }},
158+ { "green" , { 0xaca1 , 0x29aa , 0x1a45 }, { 0xffff , 0x0000 , 0xffff , 0x0000 }},
159+ { "blue" , { 0x1fd0 , 0xf000 , 0x75bb }, { 0xffff , 0x0000 , 0x0000 , 0xffff }},
160+ }
161161 },
162162 /*
163163 * colour.RGB_to_YCbCr(<rgb color in 16 bit form>,
164164 * K=colour.WEIGHTS_YCBCR["ITU-R BT.2020"],
165165 * in_bits = 16,
166166 * in_legal = False,
167167 * in_int = True,
168- * out_bits = 8 ,
168+ * out_bits = 16 ,
169169 * out_legal = False,
170170 * out_int = True)
171171 * Tests cases for color conversion generated by converting RGB
@@ -176,21 +176,21 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = {
176176 .range = DRM_COLOR_YCBCR_FULL_RANGE ,
177177 .n_colors = 6 ,
178178 .colors = {
179- { "white" , { 0xff , 0x80 , 0x80 }, { 0xffff , 0xffff , 0xffff , 0xffff }},
180- { "gray" , { 0x80 , 0x80 , 0x80 }, { 0xffff , 0x8080 , 0x8080 , 0x8080 }},
181- { "black" , { 0x00 , 0x80 , 0x80 }, { 0xffff , 0x0000 , 0x0000 , 0x0000 }},
182- { "red" , { 0x43 , 0x5c , 0xff }, { 0xffff , 0xffff , 0x0000 , 0x0000 }},
183- { "green" , { 0xad , 0x24 , 0x0b }, { 0xffff , 0x0000 , 0xffff , 0x0000 }},
184- { "blue" , { 0x0f , 0xff , 0x76 }, { 0xffff , 0x0000 , 0x0000 , 0xffff }},
185- },
179+ { "white" , { 0xffff , 0x8000 , 0x8000 }, { 0xffff , 0xffff , 0xffff , 0xffff }},
180+ { "gray" , { 0x8080 , 0x8000 , 0x8000 }, { 0xffff , 0x8080 , 0x8080 , 0x8080 }},
181+ { "black" , { 0x0000 , 0x8000 , 0x8000 }, { 0xffff , 0x0000 , 0x0000 , 0x0000 }},
182+ { "red" , { 0x4340 , 0x5c41 , 0xffff }, { 0xffff , 0xffff , 0x0000 , 0x0000 }},
183+ { "green" , { 0xad91 , 0x23bf , 0x0a4c }, { 0xffff , 0x0000 , 0xffff , 0x0000 }},
184+ { "blue" , { 0x0f2e , 0xffff , 0x75b5 }, { 0xffff , 0x0000 , 0x0000 , 0xffff }},
185+ }
186186 },
187187 /*
188188 * colour.RGB_to_YCbCr(<rgb color in 16 bit form>,
189189 * K=colour.WEIGHTS_YCBCR["ITU-R BT.2020"],
190190 * in_bits = 16,
191191 * in_legal = False,
192192 * in_int = True,
193- * out_bits = 8 ,
193+ * out_bits = 16 ,
194194 * out_legal = True,
195195 * out_int = True)
196196 * Tests cases for color conversion generated by converting RGB
@@ -201,32 +201,30 @@ static struct yuv_u8_to_argb_u16_case yuv_u8_to_argb_u16_cases[] = {
201201 .range = DRM_COLOR_YCBCR_LIMITED_RANGE ,
202202 .n_colors = 6 ,
203203 .colors = {
204- { "white" , { 0xeb , 0x80 , 0x80 }, { 0xffff , 0xffff , 0xffff , 0xffff }},
205- { "gray" , { 0x7e , 0x80 , 0x80 }, { 0xffff , 0x8080 , 0x8080 , 0x8080 }},
206- { "black" , { 0x10 , 0x80 , 0x80 }, { 0xffff , 0x0000 , 0x0000 , 0x0000 }},
207- { "red" , { 0x4a , 0x61 , 0xf0 }, { 0xffff , 0xffff , 0x0000 , 0x0000 }},
208- { "green" , { 0xa4 , 0x2f , 0x19 }, { 0xffff , 0x0000 , 0xffff , 0x0000 }},
209- { "blue" , { 0x1d , 0xf0 , 0x77 }, { 0xffff , 0x0000 , 0x0000 , 0xffff }},
210- },
204+ { "white" , { 0xeb00 , 0x8000 , 0x8000 }, { 0xffff , 0xffff , 0xffff , 0xffff }},
205+ { "gray" , { 0x7dee , 0x8000 , 0x8000 }, { 0xffff , 0x8080 , 0x8080 , 0x8080 }},
206+ { "black" , { 0x1000 , 0x8000 , 0x8000 }, { 0xffff , 0x0000 , 0x0000 , 0x0000 }},
207+ { "red" , { 0x4988 , 0x60b9 , 0xf000 }, { 0xffff , 0xffff , 0x0000 , 0x0000 }},
208+ { "green" , { 0xa47b , 0x2f47 , 0x1902 }, { 0xffff , 0x0000 , 0xffff , 0x0000 }},
209+ { "blue" , { 0x1cfd , 0xf000 , 0x76fe }, { 0xffff , 0x0000 , 0x0000 , 0xffff }},
210+ }
211211 },
212212};
213213
214214/*
215- * vkms_format_test_yuv_u8_to_argb_u16 - Testing the conversion between YUV
215+ * vkms_format_test_yuv_u16_to_argb_u16 - Testing the conversion between YUV
216216 * colors to ARGB colors in VKMS
217217 *
218218 * This test will use the functions get_conversion_matrix_to_argb_u16 and
219- * argb_u16_from_yuv888 to convert YUV colors (stored in
220- * yuv_u8_to_argb_u16_cases ) into ARGB colors.
219+ * argb_u16_from_yuv161616 to convert YUV colors (stored in
220+ * yuv_u16_to_argb_u16_cases ) into ARGB colors.
221221 *
222222 * The conversion between YUV and RGB is not totally reversible, so there may be
223223 * some difference between the expected value and the result.
224- * In addition, there may be some rounding error as the input color is 8 bits
225- * and output color is 16 bits.
226224 */
227- static void vkms_format_test_yuv_u8_to_argb_u16 (struct kunit * test )
225+ static void vkms_format_test_yuv_u16_to_argb_u16 (struct kunit * test )
228226{
229- const struct yuv_u8_to_argb_u16_case * param = test -> param_value ;
227+ const struct yuv_u16_to_argb_u16_case * param = test -> param_value ;
230228 struct pixel_argb_u16 argb ;
231229
232230 for (size_t i = 0 ; i < param -> n_colors ; i ++ ) {
@@ -236,7 +234,8 @@ static void vkms_format_test_yuv_u8_to_argb_u16(struct kunit *test)
236234 get_conversion_matrix_to_argb_u16
237235 (DRM_FORMAT_NV12 , param -> encoding , param -> range , & matrix );
238236
239- argb = argb_u16_from_yuv888 (color -> yuv .y , color -> yuv .u , color -> yuv .v , & matrix );
237+ argb = argb_u16_from_yuv161616 (& matrix , color -> yuv .y , color -> yuv .u ,
238+ color -> yuv .v );
240239
241240 KUNIT_EXPECT_LE_MSG (test , abs_diff (argb .a , color -> argb .a ), 0x1ff ,
242241 "On the A channel of the color %s expected 0x%04x, got 0x%04x" ,
@@ -253,19 +252,19 @@ static void vkms_format_test_yuv_u8_to_argb_u16(struct kunit *test)
253252 }
254253}
255254
256- static void vkms_format_test_yuv_u8_to_argb_u16_case_desc (struct yuv_u8_to_argb_u16_case * t ,
257- char * desc )
255+ static void vkms_format_test_yuv_u16_to_argb_u16_case_desc (struct yuv_u16_to_argb_u16_case * t ,
256+ char * desc )
258257{
259258 snprintf (desc , KUNIT_PARAM_DESC_SIZE , "%s - %s" ,
260259 drm_get_color_encoding_name (t -> encoding ), drm_get_color_range_name (t -> range ));
261260}
262261
263- KUNIT_ARRAY_PARAM (yuv_u8_to_argb_u16 , yuv_u8_to_argb_u16_cases ,
264- vkms_format_test_yuv_u8_to_argb_u16_case_desc
262+ KUNIT_ARRAY_PARAM (yuv_u16_to_argb_u16 , yuv_u16_to_argb_u16_cases ,
263+ vkms_format_test_yuv_u16_to_argb_u16_case_desc
265264);
266265
267266static struct kunit_case vkms_format_test_cases [] = {
268- KUNIT_CASE_PARAM (vkms_format_test_yuv_u8_to_argb_u16 , yuv_u8_to_argb_u16_gen_params ),
267+ KUNIT_CASE_PARAM (vkms_format_test_yuv_u16_to_argb_u16 , yuv_u16_to_argb_u16_gen_params ),
269268 {}
270269};
271270
0 commit comments