![]() |
|
|||
0001 /* SPDX-License-Identifier: MIT */ 0002 0003 #ifndef DRM_MODULE_H 0004 #define DRM_MODULE_H 0005 0006 #include <linux/pci.h> 0007 #include <linux/platform_device.h> 0008 0009 #include <drm/drm_drv.h> 0010 0011 /** 0012 * DOC: overview 0013 * 0014 * This library provides helpers registering DRM drivers during module 0015 * initialization and shutdown. The provided helpers act like bus-specific 0016 * module helpers, such as module_pci_driver(), but respect additional 0017 * parameters that control DRM driver registration. 0018 * 0019 * Below is an example of initializing a DRM driver for a device on the 0020 * PCI bus. 0021 * 0022 * .. code-block:: c 0023 * 0024 * struct pci_driver my_pci_drv = { 0025 * }; 0026 * 0027 * drm_module_pci_driver(my_pci_drv); 0028 * 0029 * The generated code will test if DRM drivers are enabled and register 0030 * the PCI driver my_pci_drv. For more complex module initialization, you 0031 * can still use module_init() and module_exit() in your driver. 0032 */ 0033 0034 /* 0035 * PCI drivers 0036 */ 0037 0038 static inline int __init drm_pci_register_driver(struct pci_driver *pci_drv) 0039 { 0040 if (drm_firmware_drivers_only()) 0041 return -ENODEV; 0042 0043 return pci_register_driver(pci_drv); 0044 } 0045 0046 /** 0047 * drm_module_pci_driver - Register a DRM driver for PCI-based devices 0048 * @__pci_drv: the PCI driver structure 0049 * 0050 * Registers a DRM driver for devices on the PCI bus. The helper 0051 * macro behaves like module_pci_driver() but tests the state of 0052 * drm_firmware_drivers_only(). For more complex module initialization, 0053 * use module_init() and module_exit() directly. 0054 * 0055 * Each module may only use this macro once. Calling it replaces 0056 * module_init() and module_exit(). 0057 */ 0058 #define drm_module_pci_driver(__pci_drv) \ 0059 module_driver(__pci_drv, drm_pci_register_driver, pci_unregister_driver) 0060 0061 static inline int __init 0062 drm_pci_register_driver_if_modeset(struct pci_driver *pci_drv, int modeset) 0063 { 0064 if (drm_firmware_drivers_only() && modeset == -1) 0065 return -ENODEV; 0066 if (modeset == 0) 0067 return -ENODEV; 0068 0069 return pci_register_driver(pci_drv); 0070 } 0071 0072 static inline void __exit 0073 drm_pci_unregister_driver_if_modeset(struct pci_driver *pci_drv, int modeset) 0074 { 0075 pci_unregister_driver(pci_drv); 0076 } 0077 0078 /** 0079 * drm_module_pci_driver_if_modeset - Register a DRM driver for PCI-based devices 0080 * @__pci_drv: the PCI driver structure 0081 * @__modeset: an additional parameter that disables the driver 0082 * 0083 * This macro is deprecated and only provided for existing drivers. For 0084 * new drivers, use drm_module_pci_driver(). 0085 * 0086 * Registers a DRM driver for devices on the PCI bus. The helper macro 0087 * behaves like drm_module_pci_driver() with an additional driver-specific 0088 * flag. If __modeset is 0, the driver has been disabled, if __modeset is 0089 * -1 the driver state depends on the global DRM state. For all other 0090 * values, the PCI driver has been enabled. The default should be -1. 0091 */ 0092 #define drm_module_pci_driver_if_modeset(__pci_drv, __modeset) \ 0093 module_driver(__pci_drv, drm_pci_register_driver_if_modeset, \ 0094 drm_pci_unregister_driver_if_modeset, __modeset) 0095 0096 /* 0097 * Platform drivers 0098 */ 0099 0100 static inline int __init 0101 drm_platform_driver_register(struct platform_driver *platform_drv) 0102 { 0103 if (drm_firmware_drivers_only()) 0104 return -ENODEV; 0105 0106 return platform_driver_register(platform_drv); 0107 } 0108 0109 /** 0110 * drm_module_platform_driver - Register a DRM driver for platform devices 0111 * @__platform_drv: the platform driver structure 0112 * 0113 * Registers a DRM driver for devices on the platform bus. The helper 0114 * macro behaves like module_platform_driver() but tests the state of 0115 * drm_firmware_drivers_only(). For more complex module initialization, 0116 * use module_init() and module_exit() directly. 0117 * 0118 * Each module may only use this macro once. Calling it replaces 0119 * module_init() and module_exit(). 0120 */ 0121 #define drm_module_platform_driver(__platform_drv) \ 0122 module_driver(__platform_drv, drm_platform_driver_register, \ 0123 platform_driver_unregister) 0124 0125 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |