| 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Test cases for the drm_format functions |
| 4 | * |
| 5 | * Copyright (c) 2022 MaĆra Canal <mairacanal@riseup.net> |
| 6 | */ |
| 7 | |
| 8 | #include <kunit/test.h> |
| 9 | |
| 10 | #include <drm/drm_fourcc.h> |
| 11 | |
| 12 | static void drm_test_format_block_width_invalid(struct kunit *test) |
| 13 | { |
| 14 | const struct drm_format_info *info = NULL; |
| 15 | |
| 16 | KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 0), 0); |
| 17 | KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, -1), 0); |
| 18 | KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 1), 0); |
| 19 | } |
| 20 | |
| 21 | static void drm_test_format_block_width_one_plane(struct kunit *test) |
| 22 | { |
| 23 | const struct drm_format_info *info = drm_format_info(DRM_FORMAT_XRGB4444); |
| 24 | |
| 25 | KUNIT_ASSERT_NOT_NULL(test, info); |
| 26 | |
| 27 | KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 0), 1); |
| 28 | KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 1), 0); |
| 29 | KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, -1), 0); |
| 30 | } |
| 31 | |
| 32 | static void drm_test_format_block_width_two_plane(struct kunit *test) |
| 33 | { |
| 34 | const struct drm_format_info *info = drm_format_info(DRM_FORMAT_NV12); |
| 35 | |
| 36 | KUNIT_ASSERT_NOT_NULL(test, info); |
| 37 | |
| 38 | KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 0), 1); |
| 39 | KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 1), 1); |
| 40 | KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 2), 0); |
| 41 | KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, -1), 0); |
| 42 | } |
| 43 | |
| 44 | static void drm_test_format_block_width_three_plane(struct kunit *test) |
| 45 | { |
| 46 | const struct drm_format_info *info = drm_format_info(DRM_FORMAT_YUV422); |
| 47 | |
| 48 | KUNIT_ASSERT_NOT_NULL(test, info); |
| 49 | |
| 50 | KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 0), 1); |
| 51 | KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 1), 1); |
| 52 | KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 2), 1); |
| 53 | KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 3), 0); |
| 54 | KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, -1), 0); |
| 55 | } |
| 56 | |
| 57 | static void drm_test_format_block_width_tiled(struct kunit *test) |
| 58 | { |
| 59 | const struct drm_format_info *info = drm_format_info(DRM_FORMAT_X0L0); |
| 60 | |
| 61 | KUNIT_ASSERT_NOT_NULL(test, info); |
| 62 | |
| 63 | KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 0), 2); |
| 64 | KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, 1), 0); |
| 65 | KUNIT_EXPECT_EQ(test, drm_format_info_block_width(info, -1), 0); |
| 66 | } |
| 67 | |
| 68 | static void drm_test_format_block_height_invalid(struct kunit *test) |
| 69 | { |
| 70 | const struct drm_format_info *info = NULL; |
| 71 | |
| 72 | KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 0), 0); |
| 73 | KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, -1), 0); |
| 74 | KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 1), 0); |
| 75 | } |
| 76 | |
| 77 | static void drm_test_format_block_height_one_plane(struct kunit *test) |
| 78 | { |
| 79 | const struct drm_format_info *info = drm_format_info(DRM_FORMAT_XRGB4444); |
| 80 | |
| 81 | KUNIT_ASSERT_NOT_NULL(test, info); |
| 82 | |
| 83 | KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 0), 1); |
| 84 | KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, -1), 0); |
| 85 | KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 1), 0); |
| 86 | } |
| 87 | |
| 88 | static void drm_test_format_block_height_two_plane(struct kunit *test) |
| 89 | { |
| 90 | const struct drm_format_info *info = drm_format_info(DRM_FORMAT_NV12); |
| 91 | |
| 92 | KUNIT_ASSERT_NOT_NULL(test, info); |
| 93 | |
| 94 | KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 0), 1); |
| 95 | KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 1), 1); |
| 96 | KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 2), 0); |
| 97 | KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, -1), 0); |
| 98 | } |
| 99 | |
| 100 | static void drm_test_format_block_height_three_plane(struct kunit *test) |
| 101 | { |
| 102 | const struct drm_format_info *info = drm_format_info(DRM_FORMAT_YUV422); |
| 103 | |
| 104 | KUNIT_ASSERT_NOT_NULL(test, info); |
| 105 | |
| 106 | KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 0), 1); |
| 107 | KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 1), 1); |
| 108 | KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 2), 1); |
| 109 | KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 3), 0); |
| 110 | KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, -1), 0); |
| 111 | } |
| 112 | |
| 113 | static void drm_test_format_block_height_tiled(struct kunit *test) |
| 114 | { |
| 115 | const struct drm_format_info *info = drm_format_info(DRM_FORMAT_X0L0); |
| 116 | |
| 117 | KUNIT_ASSERT_NOT_NULL(test, info); |
| 118 | |
| 119 | KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 0), 2); |
| 120 | KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, 1), 0); |
| 121 | KUNIT_EXPECT_EQ(test, drm_format_info_block_height(info, -1), 0); |
| 122 | } |
| 123 | |
| 124 | static void drm_test_format_min_pitch_invalid(struct kunit *test) |
| 125 | { |
| 126 | const struct drm_format_info *info = NULL; |
| 127 | |
| 128 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 0), 0); |
| 129 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, -1, 0), 0); |
| 130 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 0), 0); |
| 131 | } |
| 132 | |
| 133 | static void drm_test_format_min_pitch_one_plane_8bpp(struct kunit *test) |
| 134 | { |
| 135 | const struct drm_format_info *info = drm_format_info(DRM_FORMAT_RGB332); |
| 136 | |
| 137 | KUNIT_ASSERT_NOT_NULL(test, info); |
| 138 | |
| 139 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 0), 0); |
| 140 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, -1, 0), 0); |
| 141 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 0), 0); |
| 142 | |
| 143 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1), 1); |
| 144 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 2), 2); |
| 145 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 640), 640); |
| 146 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1024), 1024); |
| 147 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1920), 1920); |
| 148 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 4096), 4096); |
| 149 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 671), 671); |
| 150 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX), |
| 151 | (uint64_t)UINT_MAX); |
| 152 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, (UINT_MAX - 1)), |
| 153 | (uint64_t)(UINT_MAX - 1)); |
| 154 | } |
| 155 | |
| 156 | static void drm_test_format_min_pitch_one_plane_16bpp(struct kunit *test) |
| 157 | { |
| 158 | const struct drm_format_info *info = drm_format_info(DRM_FORMAT_XRGB4444); |
| 159 | |
| 160 | KUNIT_ASSERT_NOT_NULL(test, info); |
| 161 | |
| 162 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 0), 0); |
| 163 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, -1, 0), 0); |
| 164 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 0), 0); |
| 165 | |
| 166 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1), 2); |
| 167 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 2), 4); |
| 168 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 640), 1280); |
| 169 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1024), 2048); |
| 170 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1920), 3840); |
| 171 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 4096), 8192); |
| 172 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 671), 1342); |
| 173 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX), |
| 174 | (uint64_t)UINT_MAX * 2); |
| 175 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, (UINT_MAX - 1)), |
| 176 | (uint64_t)(UINT_MAX - 1) * 2); |
| 177 | } |
| 178 | |
| 179 | static void drm_test_format_min_pitch_one_plane_24bpp(struct kunit *test) |
| 180 | { |
| 181 | const struct drm_format_info *info = drm_format_info(DRM_FORMAT_RGB888); |
| 182 | |
| 183 | KUNIT_ASSERT_NOT_NULL(test, info); |
| 184 | |
| 185 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 0), 0); |
| 186 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, -1, 0), 0); |
| 187 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 0), 0); |
| 188 | |
| 189 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1), 3); |
| 190 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 2), 6); |
| 191 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 640), 1920); |
| 192 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1024), 3072); |
| 193 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1920), 5760); |
| 194 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 4096), 12288); |
| 195 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 671), 2013); |
| 196 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX), |
| 197 | (uint64_t)UINT_MAX * 3); |
| 198 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX - 1), |
| 199 | (uint64_t)(UINT_MAX - 1) * 3); |
| 200 | } |
| 201 | |
| 202 | static void drm_test_format_min_pitch_one_plane_32bpp(struct kunit *test) |
| 203 | { |
| 204 | const struct drm_format_info *info = drm_format_info(DRM_FORMAT_ABGR8888); |
| 205 | |
| 206 | KUNIT_ASSERT_NOT_NULL(test, info); |
| 207 | |
| 208 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 0), 0); |
| 209 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, -1, 0), 0); |
| 210 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 0), 0); |
| 211 | |
| 212 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1), 4); |
| 213 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 2), 8); |
| 214 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 640), 2560); |
| 215 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1024), 4096); |
| 216 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1920), 7680); |
| 217 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 4096), 16384); |
| 218 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 671), 2684); |
| 219 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX), |
| 220 | (uint64_t)UINT_MAX * 4); |
| 221 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX - 1), |
| 222 | (uint64_t)(UINT_MAX - 1) * 4); |
| 223 | } |
| 224 | |
| 225 | static void drm_test_format_min_pitch_two_plane(struct kunit *test) |
| 226 | { |
| 227 | const struct drm_format_info *info = drm_format_info(DRM_FORMAT_NV12); |
| 228 | |
| 229 | KUNIT_ASSERT_NOT_NULL(test, info); |
| 230 | |
| 231 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 0), 0); |
| 232 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 0), 0); |
| 233 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, -1, 0), 0); |
| 234 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, 0), 0); |
| 235 | |
| 236 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1), 1); |
| 237 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 1), 2); |
| 238 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 2), 2); |
| 239 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 1), 2); |
| 240 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 640), 640); |
| 241 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 320), 640); |
| 242 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1024), 1024); |
| 243 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 512), 1024); |
| 244 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1920), 1920); |
| 245 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 960), 1920); |
| 246 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 4096), 4096); |
| 247 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 2048), 4096); |
| 248 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 671), 671); |
| 249 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 336), 672); |
| 250 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX), |
| 251 | (uint64_t)UINT_MAX); |
| 252 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, UINT_MAX / 2 + 1), |
| 253 | (uint64_t)UINT_MAX + 1); |
| 254 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, (UINT_MAX - 1)), |
| 255 | (uint64_t)(UINT_MAX - 1)); |
| 256 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, (UINT_MAX - 1) / 2), |
| 257 | (uint64_t)(UINT_MAX - 1)); |
| 258 | } |
| 259 | |
| 260 | static void drm_test_format_min_pitch_three_plane_8bpp(struct kunit *test) |
| 261 | { |
| 262 | const struct drm_format_info *info = drm_format_info(DRM_FORMAT_YUV422); |
| 263 | |
| 264 | KUNIT_ASSERT_NOT_NULL(test, info); |
| 265 | |
| 266 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 0), 0); |
| 267 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 0), 0); |
| 268 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, 0), 0); |
| 269 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, -1, 0), 0); |
| 270 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 3, 0), 0); |
| 271 | |
| 272 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1), 1); |
| 273 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 1), 1); |
| 274 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, 1), 1); |
| 275 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 2), 2); |
| 276 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 2), 2); |
| 277 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, 2), 2); |
| 278 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 640), 640); |
| 279 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 320), 320); |
| 280 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, 320), 320); |
| 281 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1024), 1024); |
| 282 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 512), 512); |
| 283 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, 512), 512); |
| 284 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1920), 1920); |
| 285 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 960), 960); |
| 286 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, 960), 960); |
| 287 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 4096), 4096); |
| 288 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 2048), 2048); |
| 289 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, 2048), 2048); |
| 290 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 671), 671); |
| 291 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 336), 336); |
| 292 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, 336), 336); |
| 293 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX), |
| 294 | (uint64_t)UINT_MAX); |
| 295 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, UINT_MAX / 2 + 1), |
| 296 | (uint64_t)UINT_MAX / 2 + 1); |
| 297 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, UINT_MAX / 2 + 1), |
| 298 | (uint64_t)UINT_MAX / 2 + 1); |
| 299 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, (UINT_MAX - 1) / 2), |
| 300 | (uint64_t)(UINT_MAX - 1) / 2); |
| 301 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, (UINT_MAX - 1) / 2), |
| 302 | (uint64_t)(UINT_MAX - 1) / 2); |
| 303 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 2, (UINT_MAX - 1) / 2), |
| 304 | (uint64_t)(UINT_MAX - 1) / 2); |
| 305 | } |
| 306 | |
| 307 | static void drm_test_format_min_pitch_tiled(struct kunit *test) |
| 308 | { |
| 309 | const struct drm_format_info *info = drm_format_info(DRM_FORMAT_X0L2); |
| 310 | |
| 311 | KUNIT_ASSERT_NOT_NULL(test, info); |
| 312 | |
| 313 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 0), 0); |
| 314 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, -1, 0), 0); |
| 315 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 1, 0), 0); |
| 316 | |
| 317 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1), 2); |
| 318 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 2), 4); |
| 319 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 640), 1280); |
| 320 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1024), 2048); |
| 321 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 1920), 3840); |
| 322 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 4096), 8192); |
| 323 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, 671), 1342); |
| 324 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX), |
| 325 | (uint64_t)UINT_MAX * 2); |
| 326 | KUNIT_EXPECT_EQ(test, drm_format_info_min_pitch(info, 0, UINT_MAX - 1), |
| 327 | (uint64_t)(UINT_MAX - 1) * 2); |
| 328 | } |
| 329 | |
| 330 | static struct kunit_case drm_format_tests[] = { |
| 331 | KUNIT_CASE(drm_test_format_block_width_invalid), |
| 332 | KUNIT_CASE(drm_test_format_block_width_one_plane), |
| 333 | KUNIT_CASE(drm_test_format_block_width_two_plane), |
| 334 | KUNIT_CASE(drm_test_format_block_width_three_plane), |
| 335 | KUNIT_CASE(drm_test_format_block_width_tiled), |
| 336 | KUNIT_CASE(drm_test_format_block_height_invalid), |
| 337 | KUNIT_CASE(drm_test_format_block_height_one_plane), |
| 338 | KUNIT_CASE(drm_test_format_block_height_two_plane), |
| 339 | KUNIT_CASE(drm_test_format_block_height_three_plane), |
| 340 | KUNIT_CASE(drm_test_format_block_height_tiled), |
| 341 | KUNIT_CASE(drm_test_format_min_pitch_invalid), |
| 342 | KUNIT_CASE(drm_test_format_min_pitch_one_plane_8bpp), |
| 343 | KUNIT_CASE(drm_test_format_min_pitch_one_plane_16bpp), |
| 344 | KUNIT_CASE(drm_test_format_min_pitch_one_plane_24bpp), |
| 345 | KUNIT_CASE(drm_test_format_min_pitch_one_plane_32bpp), |
| 346 | KUNIT_CASE(drm_test_format_min_pitch_two_plane), |
| 347 | KUNIT_CASE(drm_test_format_min_pitch_three_plane_8bpp), |
| 348 | KUNIT_CASE(drm_test_format_min_pitch_tiled), |
| 349 | {} |
| 350 | }; |
| 351 | |
| 352 | static struct kunit_suite drm_format_test_suite = { |
| 353 | .name = "drm_format" , |
| 354 | .test_cases = drm_format_tests, |
| 355 | }; |
| 356 | |
| 357 | kunit_test_suite(drm_format_test_suite); |
| 358 | |
| 359 | MODULE_DESCRIPTION("Test cases for the drm_format functions" ); |
| 360 | MODULE_LICENSE("GPL" ); |
| 361 | |