at v6.17 98 lines 3.1 kB view raw
1// SPDX-License-Identifier: MIT 2 3#include <linux/export.h> 4 5#include <drm/clients/drm_client_setup.h> 6#include <drm/drm_device.h> 7#include <drm/drm_drv.h> 8#include <drm/drm_fourcc.h> 9#include <drm/drm_print.h> 10 11#include "drm_client_internal.h" 12 13static char drm_client_default[16] = CONFIG_DRM_CLIENT_DEFAULT; 14module_param_string(active, drm_client_default, sizeof(drm_client_default), 0444); 15MODULE_PARM_DESC(active, 16 "Choose which drm client to start, default is" 17 CONFIG_DRM_CLIENT_DEFAULT "]"); 18 19/** 20 * drm_client_setup() - Setup in-kernel DRM clients 21 * @dev: DRM device 22 * @format: Preferred pixel format for the device. Use NULL, unless 23 * there is clearly a driver-preferred format. 24 * 25 * This function sets up the in-kernel DRM clients. Restore, hotplug 26 * events and teardown are all taken care of. 27 * 28 * Drivers should call drm_client_setup() after registering the new 29 * DRM device with drm_dev_register(). This function is safe to call 30 * even when there are no connectors present. Setup will be retried 31 * on the next hotplug event. 32 * 33 * The clients are destroyed by drm_dev_unregister(). 34 */ 35void drm_client_setup(struct drm_device *dev, const struct drm_format_info *format) 36{ 37 if (!drm_core_check_feature(dev, DRIVER_MODESET)) { 38 drm_dbg(dev, "driver does not support mode-setting, skipping DRM clients\n"); 39 return; 40 } 41 42#ifdef CONFIG_DRM_FBDEV_EMULATION 43 if (!strcmp(drm_client_default, "fbdev")) { 44 int ret; 45 46 ret = drm_fbdev_client_setup(dev, format); 47 if (ret) 48 drm_warn(dev, "Failed to set up DRM client; error %d\n", ret); 49 return; 50 } 51#endif 52 53#ifdef CONFIG_DRM_CLIENT_LOG 54 if (!strcmp(drm_client_default, "log")) { 55 drm_log_register(dev); 56 return; 57 } 58#endif 59 if (strcmp(drm_client_default, "")) 60 drm_warn(dev, "Unknown DRM client %s\n", drm_client_default); 61} 62EXPORT_SYMBOL(drm_client_setup); 63 64/** 65 * drm_client_setup_with_fourcc() - Setup in-kernel DRM clients for color mode 66 * @dev: DRM device 67 * @fourcc: Preferred pixel format as 4CC code for the device 68 * 69 * This function sets up the in-kernel DRM clients. It is equivalent 70 * to drm_client_setup(), but expects a 4CC code as second argument. 71 */ 72void drm_client_setup_with_fourcc(struct drm_device *dev, u32 fourcc) 73{ 74 drm_client_setup(dev, drm_format_info(fourcc)); 75} 76EXPORT_SYMBOL(drm_client_setup_with_fourcc); 77 78/** 79 * drm_client_setup_with_color_mode() - Setup in-kernel DRM clients for color mode 80 * @dev: DRM device 81 * @color_mode: Preferred color mode for the device 82 * 83 * This function sets up the in-kernel DRM clients. It is equivalent 84 * to drm_client_setup(), but expects a color mode as second argument. 85 * 86 * Do not use this function in new drivers. Prefer drm_client_setup() with a 87 * format of NULL. 88 */ 89void drm_client_setup_with_color_mode(struct drm_device *dev, unsigned int color_mode) 90{ 91 u32 fourcc = drm_driver_color_mode_format(dev, color_mode); 92 93 drm_client_setup_with_fourcc(dev, fourcc); 94} 95EXPORT_SYMBOL(drm_client_setup_with_color_mode); 96 97MODULE_DESCRIPTION("In-kernel DRM clients"); 98MODULE_LICENSE("GPL and additional rights");