drm_client.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _DRM_CLIENT_H_
  3. #define _DRM_CLIENT_H_
  4. #include <linux/types.h>
  5. struct drm_client_dev;
  6. struct drm_device;
  7. struct drm_file;
  8. struct drm_framebuffer;
  9. struct drm_gem_object;
  10. struct drm_minor;
  11. struct module;
  12. /**
  13. * struct drm_client_funcs - DRM client callbacks
  14. */
  15. struct drm_client_funcs {
  16. /**
  17. * @owner: The module owner
  18. */
  19. struct module *owner;
  20. /**
  21. * @unregister:
  22. *
  23. * Called when &drm_device is unregistered. The client should respond by
  24. * releasing it's resources using drm_client_release().
  25. *
  26. * This callback is optional.
  27. */
  28. void (*unregister)(struct drm_client_dev *client);
  29. /**
  30. * @restore:
  31. *
  32. * Called on drm_lastclose(). The first client instance in the list that
  33. * returns zero gets the privilege to restore and no more clients are
  34. * called. This callback is not called after @unregister has been called.
  35. *
  36. * This callback is optional.
  37. */
  38. int (*restore)(struct drm_client_dev *client);
  39. /**
  40. * @hotplug:
  41. *
  42. * Called on drm_kms_helper_hotplug_event().
  43. * This callback is not called after @unregister has been called.
  44. *
  45. * This callback is optional.
  46. */
  47. int (*hotplug)(struct drm_client_dev *client);
  48. };
  49. /**
  50. * struct drm_client_dev - DRM client instance
  51. */
  52. struct drm_client_dev {
  53. /**
  54. * @dev: DRM device
  55. */
  56. struct drm_device *dev;
  57. /**
  58. * @name: Name of the client.
  59. */
  60. const char *name;
  61. /**
  62. * @list:
  63. *
  64. * List of all clients of a DRM device, linked into
  65. * &drm_device.clientlist. Protected by &drm_device.clientlist_mutex.
  66. */
  67. struct list_head list;
  68. /**
  69. * @funcs: DRM client functions (optional)
  70. */
  71. const struct drm_client_funcs *funcs;
  72. /**
  73. * @file: DRM file
  74. */
  75. struct drm_file *file;
  76. };
  77. int drm_client_init(struct drm_device *dev, struct drm_client_dev *client,
  78. const char *name, const struct drm_client_funcs *funcs);
  79. void drm_client_release(struct drm_client_dev *client);
  80. void drm_client_add(struct drm_client_dev *client);
  81. void drm_client_dev_unregister(struct drm_device *dev);
  82. void drm_client_dev_hotplug(struct drm_device *dev);
  83. void drm_client_dev_restore(struct drm_device *dev);
  84. /**
  85. * struct drm_client_buffer - DRM client buffer
  86. */
  87. struct drm_client_buffer {
  88. /**
  89. * @client: DRM client
  90. */
  91. struct drm_client_dev *client;
  92. /**
  93. * @handle: Buffer handle
  94. */
  95. u32 handle;
  96. /**
  97. * @pitch: Buffer pitch
  98. */
  99. u32 pitch;
  100. /**
  101. * @gem: GEM object backing this buffer
  102. */
  103. struct drm_gem_object *gem;
  104. /**
  105. * @vaddr: Virtual address for the buffer
  106. */
  107. void *vaddr;
  108. /**
  109. * @fb: DRM framebuffer
  110. */
  111. struct drm_framebuffer *fb;
  112. };
  113. struct drm_client_buffer *
  114. drm_client_framebuffer_create(struct drm_client_dev *client, u32 width, u32 height, u32 format);
  115. void drm_client_framebuffer_delete(struct drm_client_buffer *buffer);
  116. int drm_client_debugfs_init(struct drm_minor *minor);
  117. #endif