drm_client_setup.c 2.1 KB

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