~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/drm/drm_kunit_helpers.h

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0
  2 
  3 #ifndef DRM_KUNIT_HELPERS_H_
  4 #define DRM_KUNIT_HELPERS_H_
  5 
  6 #include <drm/drm_drv.h>
  7 
  8 #include <linux/device.h>
  9 
 10 #include <kunit/test.h>
 11 
 12 struct drm_crtc_funcs;
 13 struct drm_crtc_helper_funcs;
 14 struct drm_device;
 15 struct drm_plane_funcs;
 16 struct drm_plane_helper_funcs;
 17 struct kunit;
 18 
 19 struct device *drm_kunit_helper_alloc_device(struct kunit *test);
 20 void drm_kunit_helper_free_device(struct kunit *test, struct device *dev);
 21 
 22 struct drm_device *
 23 __drm_kunit_helper_alloc_drm_device_with_driver(struct kunit *test,
 24                                                 struct device *dev,
 25                                                 size_t size, size_t offset,
 26                                                 const struct drm_driver *driver);
 27 
 28 /**
 29  * drm_kunit_helper_alloc_drm_device_with_driver - Allocates a mock DRM device for KUnit tests
 30  * @_test: The test context object
 31  * @_dev: The parent device object
 32  * @_type: the type of the struct which contains struct &drm_device
 33  * @_member: the name of the &drm_device within @_type.
 34  * @_drv: Mocked DRM device driver features
 35  *
 36  * This function creates a struct &drm_device from @_dev and @_drv.
 37  *
 38  * @_dev should be allocated using drm_kunit_helper_alloc_device().
 39  *
 40  * The driver is tied to the @_test context and will get cleaned at the
 41  * end of the test. The drm_device is allocated through
 42  * devm_drm_dev_alloc() and will thus be freed through a device-managed
 43  * resource.
 44  *
 45  * Returns:
 46  * A pointer to the new drm_device, or an ERR_PTR() otherwise.
 47  */
 48 #define drm_kunit_helper_alloc_drm_device_with_driver(_test, _dev, _type, _member, _drv)        \
 49         ((_type *)__drm_kunit_helper_alloc_drm_device_with_driver(_test, _dev,                  \
 50                                                        sizeof(_type),                           \
 51                                                        offsetof(_type, _member),                \
 52                                                        _drv))
 53 
 54 static inline struct drm_device *
 55 __drm_kunit_helper_alloc_drm_device(struct kunit *test,
 56                                     struct device *dev,
 57                                     size_t size, size_t offset,
 58                                     u32 features)
 59 {
 60         struct drm_driver *driver;
 61 
 62         driver = devm_kzalloc(dev, sizeof(*driver), GFP_KERNEL);
 63         KUNIT_ASSERT_NOT_NULL(test, driver);
 64 
 65         driver->driver_features = features;
 66 
 67         return __drm_kunit_helper_alloc_drm_device_with_driver(test, dev,
 68                                                                size, offset,
 69                                                                driver);
 70 }
 71 
 72 /**
 73  * drm_kunit_helper_alloc_drm_device - Allocates a mock DRM device for KUnit tests
 74  * @_test: The test context object
 75  * @_dev: The parent device object
 76  * @_type: the type of the struct which contains struct &drm_device
 77  * @_member: the name of the &drm_device within @_type.
 78  * @_feat: Mocked DRM device driver features
 79  *
 80  * This function creates a struct &drm_driver and will create a struct
 81  * &drm_device from @_dev and that driver.
 82  *
 83  * @_dev should be allocated using drm_kunit_helper_alloc_device().
 84  *
 85  * The driver is tied to the @_test context and will get cleaned at the
 86  * end of the test. The drm_device is allocated through
 87  * devm_drm_dev_alloc() and will thus be freed through a device-managed
 88  * resource.
 89  *
 90  * Returns:
 91  * A pointer to the new drm_device, or an ERR_PTR() otherwise.
 92  */
 93 #define drm_kunit_helper_alloc_drm_device(_test, _dev, _type, _member, _feat)   \
 94         ((_type *)__drm_kunit_helper_alloc_drm_device(_test, _dev,              \
 95                                                       sizeof(_type),            \
 96                                                       offsetof(_type, _member), \
 97                                                       _feat))
 98 struct drm_modeset_acquire_ctx *
 99 drm_kunit_helper_acquire_ctx_alloc(struct kunit *test);
100 
101 struct drm_atomic_state *
102 drm_kunit_helper_atomic_state_alloc(struct kunit *test,
103                                     struct drm_device *drm,
104                                     struct drm_modeset_acquire_ctx *ctx);
105 
106 struct drm_plane *
107 drm_kunit_helper_create_primary_plane(struct kunit *test,
108                                       struct drm_device *drm,
109                                       const struct drm_plane_funcs *funcs,
110                                       const struct drm_plane_helper_funcs *helper_funcs,
111                                       const uint32_t *formats,
112                                       unsigned int num_formats,
113                                       const uint64_t *modifiers);
114 
115 struct drm_crtc *
116 drm_kunit_helper_create_crtc(struct kunit *test,
117                              struct drm_device *drm,
118                              struct drm_plane *primary,
119                              struct drm_plane *cursor,
120                              const struct drm_crtc_funcs *funcs,
121                              const struct drm_crtc_helper_funcs *helper_funcs);
122 
123 #endif // DRM_KUNIT_HELPERS_H_
124 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php