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