1 // SPDX-License-Identifier: MIT 2 3 #include <drm/drm_client_setup.h> 4 #include <drm/drm_device.h> 5 #include <drm/drm_fbdev_client.h> 6 #include <drm/drm_fourcc.h> 7 #include <drm/drm_print.h> 8 9 /** 10 * drm_client_setup() - Setup in-kernel DRM clients 11 * @dev: DRM device 12 * @format: Preferred pixel format for the device. Use NULL, unless 13 * there is clearly a driver-preferred format. 14 * 15 * This function sets up the in-kernel DRM clients. Restore, hotplug 16 * events and teardown are all taken care of. 17 * 18 * Drivers should call drm_client_setup() after registering the new 19 * DRM device with drm_dev_register(). This function is safe to call 20 * even when there are no connectors present. Setup will be retried 21 * on the next hotplug event. 22 * 23 * The clients are destroyed by drm_dev_unregister(). 24 */ 25 void drm_client_setup(struct drm_device *dev, const struct drm_format_info *format) 26 { 27 int ret; 28 29 ret = drm_fbdev_client_setup(dev, format); 30 if (ret) 31 drm_warn(dev, "Failed to set up DRM client; error %d\n", ret); 32 } 33 EXPORT_SYMBOL(drm_client_setup); 34 35 /** 36 * drm_client_setup_with_fourcc() - Setup in-kernel DRM clients for color mode 37 * @dev: DRM device 38 * @fourcc: Preferred pixel format as 4CC code for the device 39 * 40 * This function sets up the in-kernel DRM clients. It is equivalent 41 * to drm_client_setup(), but expects a 4CC code as second argument. 42 */ 43 void drm_client_setup_with_fourcc(struct drm_device *dev, u32 fourcc) 44 { 45 drm_client_setup(dev, drm_format_info(fourcc)); 46 } 47 EXPORT_SYMBOL(drm_client_setup_with_fourcc); 48 49 /** 50 * drm_client_setup_with_color_mode() - Setup in-kernel DRM clients for color mode 51 * @dev: DRM device 52 * @color_mode: Preferred color mode for the device 53 * 54 * This function sets up the in-kernel DRM clients. It is equivalent 55 * to drm_client_setup(), but expects a color mode as second argument. 56 * 57 * Do not use this function in new drivers. Prefer drm_client_setup() with a 58 * format of NULL. 59 */ 60 void drm_client_setup_with_color_mode(struct drm_device *dev, unsigned int color_mode) 61 { 62 u32 fourcc = drm_driver_color_mode_format(dev, color_mode); 63 64 drm_client_setup_with_fourcc(dev, fourcc); 65 } 66 EXPORT_SYMBOL(drm_client_setup_with_color_mode); 67 68 MODULE_DESCRIPTION("In-kernel DRM clients"); 69 MODULE_LICENSE("GPL and additional rights"); 70