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