xref: /OK3568_Linux_fs/kernel/drivers/gpu/drm/selftests/test-drm_format.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun // SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Test cases for the drm_format functions
4*4882a593Smuzhiyun  */
5*4882a593Smuzhiyun 
6*4882a593Smuzhiyun #define pr_fmt(fmt) "drm_format: " fmt
7*4882a593Smuzhiyun 
8*4882a593Smuzhiyun #include <linux/errno.h>
9*4882a593Smuzhiyun #include <linux/kernel.h>
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun #include <drm/drm_fourcc.h>
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun #include "test-drm_modeset_common.h"
14*4882a593Smuzhiyun 
igt_check_drm_format_block_width(void * ignored)15*4882a593Smuzhiyun int igt_check_drm_format_block_width(void *ignored)
16*4882a593Smuzhiyun {
17*4882a593Smuzhiyun 	const struct drm_format_info *info = NULL;
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun 	/* Test invalid arguments */
20*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_width(info, 0) != 0);
21*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_width(info, -1) != 0);
22*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_width(info, 1) != 0);
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun 	/* Test 1 plane format */
25*4882a593Smuzhiyun 	info = drm_format_info(DRM_FORMAT_XRGB4444);
26*4882a593Smuzhiyun 	FAIL_ON(!info);
27*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_width(info, 0) != 1);
28*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_width(info, 1) != 0);
29*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_width(info, -1) != 0);
30*4882a593Smuzhiyun 
31*4882a593Smuzhiyun 	/* Test 2 planes format */
32*4882a593Smuzhiyun 	info = drm_format_info(DRM_FORMAT_NV12);
33*4882a593Smuzhiyun 	FAIL_ON(!info);
34*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_width(info, 0) != 1);
35*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_width(info, 1) != 1);
36*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_width(info, 2) != 0);
37*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_width(info, -1) != 0);
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun 	/* Test 3 planes format */
40*4882a593Smuzhiyun 	info = drm_format_info(DRM_FORMAT_YUV422);
41*4882a593Smuzhiyun 	FAIL_ON(!info);
42*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_width(info, 0) != 1);
43*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_width(info, 1) != 1);
44*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_width(info, 2) != 1);
45*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_width(info, 3) != 0);
46*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_width(info, -1) != 0);
47*4882a593Smuzhiyun 
48*4882a593Smuzhiyun 	/* Test a tiled format */
49*4882a593Smuzhiyun 	info = drm_format_info(DRM_FORMAT_X0L0);
50*4882a593Smuzhiyun 	FAIL_ON(!info);
51*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_width(info, 0) != 2);
52*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_width(info, 1) != 0);
53*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_width(info, -1) != 0);
54*4882a593Smuzhiyun 
55*4882a593Smuzhiyun 	return 0;
56*4882a593Smuzhiyun }
57*4882a593Smuzhiyun 
igt_check_drm_format_block_height(void * ignored)58*4882a593Smuzhiyun int igt_check_drm_format_block_height(void *ignored)
59*4882a593Smuzhiyun {
60*4882a593Smuzhiyun 	const struct drm_format_info *info = NULL;
61*4882a593Smuzhiyun 
62*4882a593Smuzhiyun 	/* Test invalid arguments */
63*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_height(info, 0) != 0);
64*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_height(info, -1) != 0);
65*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_height(info, 1) != 0);
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun 	/* Test 1 plane format */
68*4882a593Smuzhiyun 	info = drm_format_info(DRM_FORMAT_XRGB4444);
69*4882a593Smuzhiyun 	FAIL_ON(!info);
70*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_height(info, 0) != 1);
71*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_height(info, 1) != 0);
72*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_height(info, -1) != 0);
73*4882a593Smuzhiyun 
74*4882a593Smuzhiyun 	/* Test 2 planes format */
75*4882a593Smuzhiyun 	info = drm_format_info(DRM_FORMAT_NV12);
76*4882a593Smuzhiyun 	FAIL_ON(!info);
77*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_height(info, 0) != 1);
78*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_height(info, 1) != 1);
79*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_height(info, 2) != 0);
80*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_height(info, -1) != 0);
81*4882a593Smuzhiyun 
82*4882a593Smuzhiyun 	/* Test 3 planes format */
83*4882a593Smuzhiyun 	info = drm_format_info(DRM_FORMAT_YUV422);
84*4882a593Smuzhiyun 	FAIL_ON(!info);
85*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_height(info, 0) != 1);
86*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_height(info, 1) != 1);
87*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_height(info, 2) != 1);
88*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_height(info, 3) != 0);
89*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_height(info, -1) != 0);
90*4882a593Smuzhiyun 
91*4882a593Smuzhiyun 	/* Test a tiled format */
92*4882a593Smuzhiyun 	info = drm_format_info(DRM_FORMAT_X0L0);
93*4882a593Smuzhiyun 	FAIL_ON(!info);
94*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_height(info, 0) != 2);
95*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_height(info, 1) != 0);
96*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_block_height(info, -1) != 0);
97*4882a593Smuzhiyun 
98*4882a593Smuzhiyun 	return 0;
99*4882a593Smuzhiyun }
100*4882a593Smuzhiyun 
igt_check_drm_format_min_pitch(void * ignored)101*4882a593Smuzhiyun int igt_check_drm_format_min_pitch(void *ignored)
102*4882a593Smuzhiyun {
103*4882a593Smuzhiyun 	const struct drm_format_info *info = NULL;
104*4882a593Smuzhiyun 
105*4882a593Smuzhiyun 	/* Test invalid arguments */
106*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 0) != 0);
107*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, -1, 0) != 0);
108*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 1, 0) != 0);
109*4882a593Smuzhiyun 
110*4882a593Smuzhiyun 	/* Test 1 plane 8 bits per pixel format */
111*4882a593Smuzhiyun 	info = drm_format_info(DRM_FORMAT_RGB332);
112*4882a593Smuzhiyun 	FAIL_ON(!info);
113*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 0) != 0);
114*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, -1, 0) != 0);
115*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 1, 0) != 0);
116*4882a593Smuzhiyun 
117*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 1) != 1);
118*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 2) != 2);
119*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 640) != 640);
120*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 1024) != 1024);
121*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 1920) != 1920);
122*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 4096) != 4096);
123*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 671) != 671);
124*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, UINT_MAX) !=
125*4882a593Smuzhiyun 			(uint64_t)UINT_MAX);
126*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, (UINT_MAX - 1)) !=
127*4882a593Smuzhiyun 			(uint64_t)(UINT_MAX - 1));
128*4882a593Smuzhiyun 
129*4882a593Smuzhiyun 	/* Test 1 plane 16 bits per pixel format */
130*4882a593Smuzhiyun 	info = drm_format_info(DRM_FORMAT_XRGB4444);
131*4882a593Smuzhiyun 	FAIL_ON(!info);
132*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 0) != 0);
133*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, -1, 0) != 0);
134*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 1, 0) != 0);
135*4882a593Smuzhiyun 
136*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 1) != 2);
137*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 2) != 4);
138*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 640) != 1280);
139*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 1024) != 2048);
140*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 1920) != 3840);
141*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 4096) != 8192);
142*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 671) != 1342);
143*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, UINT_MAX) !=
144*4882a593Smuzhiyun 			(uint64_t)UINT_MAX * 2);
145*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, (UINT_MAX - 1)) !=
146*4882a593Smuzhiyun 			(uint64_t)(UINT_MAX - 1) * 2);
147*4882a593Smuzhiyun 
148*4882a593Smuzhiyun 	/* Test 1 plane 24 bits per pixel format */
149*4882a593Smuzhiyun 	info = drm_format_info(DRM_FORMAT_RGB888);
150*4882a593Smuzhiyun 	FAIL_ON(!info);
151*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 0) != 0);
152*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, -1, 0) != 0);
153*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 1, 0) != 0);
154*4882a593Smuzhiyun 
155*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 1) != 3);
156*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 2) != 6);
157*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 640) != 1920);
158*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 1024) != 3072);
159*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 1920) != 5760);
160*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 4096) != 12288);
161*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 671) != 2013);
162*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, UINT_MAX) !=
163*4882a593Smuzhiyun 			(uint64_t)UINT_MAX * 3);
164*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, UINT_MAX - 1) !=
165*4882a593Smuzhiyun 			(uint64_t)(UINT_MAX - 1) * 3);
166*4882a593Smuzhiyun 
167*4882a593Smuzhiyun 	/* Test 1 plane 32 bits per pixel format */
168*4882a593Smuzhiyun 	info = drm_format_info(DRM_FORMAT_ABGR8888);
169*4882a593Smuzhiyun 	FAIL_ON(!info);
170*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 0) != 0);
171*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, -1, 0) != 0);
172*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 1, 0) != 0);
173*4882a593Smuzhiyun 
174*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 1) != 4);
175*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 2) != 8);
176*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 640) != 2560);
177*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 1024) != 4096);
178*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 1920) != 7680);
179*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 4096) != 16384);
180*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 671) != 2684);
181*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, UINT_MAX) !=
182*4882a593Smuzhiyun 			(uint64_t)UINT_MAX * 4);
183*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, UINT_MAX - 1) !=
184*4882a593Smuzhiyun 			(uint64_t)(UINT_MAX - 1) * 4);
185*4882a593Smuzhiyun 
186*4882a593Smuzhiyun 	/* Test 2 planes format */
187*4882a593Smuzhiyun 	info = drm_format_info(DRM_FORMAT_NV12);
188*4882a593Smuzhiyun 	FAIL_ON(!info);
189*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 0) != 0);
190*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 1, 0) != 0);
191*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, -1, 0) != 0);
192*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 2, 0) != 0);
193*4882a593Smuzhiyun 
194*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 1) != 1);
195*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 1, 1) != 2);
196*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 2) != 2);
197*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 1, 1) != 2);
198*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 640) != 640);
199*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 1, 320) != 640);
200*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 1024) != 1024);
201*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 1, 512) != 1024);
202*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 1920) != 1920);
203*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 1, 960) != 1920);
204*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 4096) != 4096);
205*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 1, 2048) != 4096);
206*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 671) != 671);
207*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 1, 336) != 672);
208*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, UINT_MAX) !=
209*4882a593Smuzhiyun 			(uint64_t)UINT_MAX);
210*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 1, UINT_MAX / 2 + 1) !=
211*4882a593Smuzhiyun 			(uint64_t)UINT_MAX + 1);
212*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, (UINT_MAX - 1)) !=
213*4882a593Smuzhiyun 			(uint64_t)(UINT_MAX - 1));
214*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 1, (UINT_MAX - 1) /  2) !=
215*4882a593Smuzhiyun 			(uint64_t)(UINT_MAX - 1));
216*4882a593Smuzhiyun 
217*4882a593Smuzhiyun 	/* Test 3 planes 8 bits per pixel format */
218*4882a593Smuzhiyun 	info = drm_format_info(DRM_FORMAT_YUV422);
219*4882a593Smuzhiyun 	FAIL_ON(!info);
220*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 0) != 0);
221*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 1, 0) != 0);
222*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 2, 0) != 0);
223*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, -1, 0) != 0);
224*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 3, 0) != 0);
225*4882a593Smuzhiyun 
226*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 1) != 1);
227*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 1, 1) != 1);
228*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 2, 1) != 1);
229*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 2) != 2);
230*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 1, 2) != 2);
231*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 2, 2) != 2);
232*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 640) != 640);
233*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 1, 320) != 320);
234*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 2, 320) != 320);
235*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 1024) != 1024);
236*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 1, 512) != 512);
237*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 2, 512) != 512);
238*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 1920) != 1920);
239*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 1, 960) != 960);
240*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 2, 960) != 960);
241*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 4096) != 4096);
242*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 1, 2048) != 2048);
243*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 2, 2048) != 2048);
244*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 671) != 671);
245*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 1, 336) != 336);
246*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 2, 336) != 336);
247*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, UINT_MAX) !=
248*4882a593Smuzhiyun 			(uint64_t)UINT_MAX);
249*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 1, UINT_MAX / 2 + 1) !=
250*4882a593Smuzhiyun 			(uint64_t)UINT_MAX / 2 + 1);
251*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 2, UINT_MAX / 2 + 1) !=
252*4882a593Smuzhiyun 			(uint64_t)UINT_MAX / 2 + 1);
253*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, (UINT_MAX - 1) / 2) !=
254*4882a593Smuzhiyun 			(uint64_t)(UINT_MAX - 1) / 2);
255*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 1, (UINT_MAX - 1) / 2) !=
256*4882a593Smuzhiyun 			(uint64_t)(UINT_MAX - 1) / 2);
257*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 2, (UINT_MAX - 1) / 2) !=
258*4882a593Smuzhiyun 			(uint64_t)(UINT_MAX - 1) / 2);
259*4882a593Smuzhiyun 
260*4882a593Smuzhiyun 	/* Test tiled format */
261*4882a593Smuzhiyun 	info = drm_format_info(DRM_FORMAT_X0L2);
262*4882a593Smuzhiyun 	FAIL_ON(!info);
263*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 0) != 0);
264*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, -1, 0) != 0);
265*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 1, 0) != 0);
266*4882a593Smuzhiyun 
267*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 1) != 2);
268*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 2) != 4);
269*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 640) != 1280);
270*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 1024) != 2048);
271*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 1920) != 3840);
272*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 4096) != 8192);
273*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, 671) != 1342);
274*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, UINT_MAX) !=
275*4882a593Smuzhiyun 			(uint64_t)UINT_MAX * 2);
276*4882a593Smuzhiyun 	FAIL_ON(drm_format_info_min_pitch(info, 0, UINT_MAX - 1) !=
277*4882a593Smuzhiyun 			(uint64_t)(UINT_MAX - 1) * 2);
278*4882a593Smuzhiyun 
279*4882a593Smuzhiyun 	return 0;
280*4882a593Smuzhiyun }
281