1
2
3#ifndef _DRM_CLIENT_H_
4#define _DRM_CLIENT_H_
5
6#include <linux/dma-buf-map.h>
7#include <linux/lockdep.h>
8#include <linux/mutex.h>
9#include <linux/types.h>
10
11#include <drm/drm_connector.h>
12#include <drm/drm_crtc.h>
13
14struct drm_client_dev;
15struct drm_device;
16struct drm_file;
17struct drm_framebuffer;
18struct drm_gem_object;
19struct drm_minor;
20struct module;
21
22
23
24
25struct drm_client_funcs {
26
27
28
29 struct module *owner;
30
31
32
33
34
35
36
37
38
39 void (*unregister)(struct drm_client_dev *client);
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55 int (*restore)(struct drm_client_dev *client);
56
57
58
59
60
61
62
63
64
65 int (*hotplug)(struct drm_client_dev *client);
66};
67
68
69
70
71struct drm_client_dev {
72
73
74
75 struct drm_device *dev;
76
77
78
79
80 const char *name;
81
82
83
84
85
86
87
88 struct list_head list;
89
90
91
92
93 const struct drm_client_funcs *funcs;
94
95
96
97
98 struct drm_file *file;
99
100
101
102
103 struct mutex modeset_mutex;
104
105
106
107
108 struct drm_mode_set *modesets;
109};
110
111int drm_client_init(struct drm_device *dev, struct drm_client_dev *client,
112 const char *name, const struct drm_client_funcs *funcs);
113void drm_client_release(struct drm_client_dev *client);
114void drm_client_register(struct drm_client_dev *client);
115
116void drm_client_dev_unregister(struct drm_device *dev);
117void drm_client_dev_hotplug(struct drm_device *dev);
118void drm_client_dev_restore(struct drm_device *dev);
119
120
121
122
123struct drm_client_buffer {
124
125
126
127 struct drm_client_dev *client;
128
129
130
131
132 u32 handle;
133
134
135
136
137 u32 pitch;
138
139
140
141
142 struct drm_gem_object *gem;
143
144
145
146
147 struct dma_buf_map map;
148
149
150
151
152 struct drm_framebuffer *fb;
153};
154
155struct drm_client_buffer *
156drm_client_framebuffer_create(struct drm_client_dev *client, u32 width, u32 height, u32 format);
157void drm_client_framebuffer_delete(struct drm_client_buffer *buffer);
158int drm_client_framebuffer_flush(struct drm_client_buffer *buffer, struct drm_rect *rect);
159int drm_client_buffer_vmap(struct drm_client_buffer *buffer, struct dma_buf_map *map);
160void drm_client_buffer_vunmap(struct drm_client_buffer *buffer);
161
162int drm_client_modeset_create(struct drm_client_dev *client);
163void drm_client_modeset_free(struct drm_client_dev *client);
164int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width, unsigned int height);
165bool drm_client_rotation(struct drm_mode_set *modeset, unsigned int *rotation);
166int drm_client_modeset_check(struct drm_client_dev *client);
167int drm_client_modeset_commit_locked(struct drm_client_dev *client);
168int drm_client_modeset_commit(struct drm_client_dev *client);
169int drm_client_modeset_dpms(struct drm_client_dev *client, int mode);
170
171
172
173
174
175
176#define drm_client_for_each_modeset(modeset, client) \
177 for (({ lockdep_assert_held(&(client)->modeset_mutex); }), \
178 modeset = (client)->modesets; modeset->crtc; modeset++)
179
180
181
182
183
184
185
186
187
188
189
190#define drm_client_for_each_connector_iter(connector, iter) \
191 drm_for_each_connector_iter(connector, iter) \
192 if (connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK)
193
194void drm_client_debugfs_init(struct drm_minor *minor);
195
196#endif
197