|
3 | 3 | #include <drm/drm_atomic.h>
|
4 | 4 | #include <drm/drm_atomic_helper.h>
|
5 | 5 | #include <drm/drm_drv.h>
|
| 6 | +#include <drm/drm_edid.h> |
6 | 7 | #include <drm/drm_fourcc.h>
|
7 | 8 | #include <drm/drm_kunit_helpers.h>
|
8 | 9 | #include <drm/drm_managed.h>
|
@@ -311,6 +312,47 @@ drm_kunit_helper_create_crtc(struct kunit *test,
|
311 | 312 | }
|
312 | 313 | EXPORT_SYMBOL_GPL(drm_kunit_helper_create_crtc);
|
313 | 314 |
|
| 315 | +static void kunit_action_drm_mode_destroy(void *ptr) |
| 316 | +{ |
| 317 | + struct drm_display_mode *mode = ptr; |
| 318 | + |
| 319 | + drm_mode_destroy(NULL, mode); |
| 320 | +} |
| 321 | + |
| 322 | +/** |
| 323 | + * drm_kunit_display_mode_from_cea_vic() - return a mode for CEA VIC |
| 324 | + for a KUnit test |
| 325 | + * @test: The test context object |
| 326 | + * @dev: DRM device |
| 327 | + * @video_code: CEA VIC of the mode |
| 328 | + * |
| 329 | + * Creates a new mode matching the specified CEA VIC for a KUnit test. |
| 330 | + * |
| 331 | + * Resources will be cleaned up automatically. |
| 332 | + * |
| 333 | + * Returns: A new drm_display_mode on success or NULL on failure |
| 334 | + */ |
| 335 | +struct drm_display_mode * |
| 336 | +drm_kunit_display_mode_from_cea_vic(struct kunit *test, struct drm_device *dev, |
| 337 | + u8 video_code) |
| 338 | +{ |
| 339 | + struct drm_display_mode *mode; |
| 340 | + int ret; |
| 341 | + |
| 342 | + mode = drm_display_mode_from_cea_vic(dev, video_code); |
| 343 | + if (!mode) |
| 344 | + return NULL; |
| 345 | + |
| 346 | + ret = kunit_add_action_or_reset(test, |
| 347 | + kunit_action_drm_mode_destroy, |
| 348 | + mode); |
| 349 | + if (ret) |
| 350 | + return NULL; |
| 351 | + |
| 352 | + return mode; |
| 353 | +} |
| 354 | +EXPORT_SYMBOL_GPL(drm_kunit_display_mode_from_cea_vic); |
| 355 | + |
314 | 356 | MODULE_AUTHOR( "Maxime Ripard <[email protected]>");
|
315 | 357 | MODULE_DESCRIPTION("KUnit test suite helper functions");
|
316 | 358 | MODULE_LICENSE("GPL");
|
0 commit comments