Path: blob/master/drivers/gpu/drm/clients/drm_client_setup.c
26493 views
// SPDX-License-Identifier: MIT12#include <linux/export.h>34#include <drm/clients/drm_client_setup.h>5#include <drm/drm_device.h>6#include <drm/drm_drv.h>7#include <drm/drm_fourcc.h>8#include <drm/drm_print.h>910#include "drm_client_internal.h"1112static char drm_client_default[16] = CONFIG_DRM_CLIENT_DEFAULT;13module_param_string(active, drm_client_default, sizeof(drm_client_default), 0444);14MODULE_PARM_DESC(active,15"Choose which drm client to start, default is"16CONFIG_DRM_CLIENT_DEFAULT "]");1718/**19* drm_client_setup() - Setup in-kernel DRM clients20* @dev: DRM device21* @format: Preferred pixel format for the device. Use NULL, unless22* there is clearly a driver-preferred format.23*24* This function sets up the in-kernel DRM clients. Restore, hotplug25* events and teardown are all taken care of.26*27* Drivers should call drm_client_setup() after registering the new28* DRM device with drm_dev_register(). This function is safe to call29* even when there are no connectors present. Setup will be retried30* on the next hotplug event.31*32* The clients are destroyed by drm_dev_unregister().33*/34void drm_client_setup(struct drm_device *dev, const struct drm_format_info *format)35{36if (!drm_core_check_feature(dev, DRIVER_MODESET)) {37drm_dbg(dev, "driver does not support mode-setting, skipping DRM clients\n");38return;39}4041#ifdef CONFIG_DRM_FBDEV_EMULATION42if (!strcmp(drm_client_default, "fbdev")) {43int ret;4445ret = drm_fbdev_client_setup(dev, format);46if (ret)47drm_warn(dev, "Failed to set up DRM client; error %d\n", ret);48return;49}50#endif5152#ifdef CONFIG_DRM_CLIENT_LOG53if (!strcmp(drm_client_default, "log")) {54drm_log_register(dev);55return;56}57#endif58if (strcmp(drm_client_default, ""))59drm_warn(dev, "Unknown DRM client %s\n", drm_client_default);60}61EXPORT_SYMBOL(drm_client_setup);6263/**64* drm_client_setup_with_fourcc() - Setup in-kernel DRM clients for color mode65* @dev: DRM device66* @fourcc: Preferred pixel format as 4CC code for the device67*68* This function sets up the in-kernel DRM clients. It is equivalent69* to drm_client_setup(), but expects a 4CC code as second argument.70*/71void drm_client_setup_with_fourcc(struct drm_device *dev, u32 fourcc)72{73drm_client_setup(dev, drm_format_info(fourcc));74}75EXPORT_SYMBOL(drm_client_setup_with_fourcc);7677/**78* drm_client_setup_with_color_mode() - Setup in-kernel DRM clients for color mode79* @dev: DRM device80* @color_mode: Preferred color mode for the device81*82* This function sets up the in-kernel DRM clients. It is equivalent83* to drm_client_setup(), but expects a color mode as second argument.84*85* Do not use this function in new drivers. Prefer drm_client_setup() with a86* format of NULL.87*/88void drm_client_setup_with_color_mode(struct drm_device *dev, unsigned int color_mode)89{90u32 fourcc = drm_driver_color_mode_format(dev, color_mode);9192drm_client_setup_with_fourcc(dev, fourcc);93}94EXPORT_SYMBOL(drm_client_setup_with_color_mode);9596MODULE_DESCRIPTION("In-kernel DRM clients");97MODULE_LICENSE("GPL and additional rights");9899100