.. | .. |
---|
1 | | -/* SPDX-License-Identifier: GPL-2.0 */ |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0 or MIT */ |
---|
2 | 2 | |
---|
3 | 3 | #ifndef _DRM_CLIENT_H_ |
---|
4 | 4 | #define _DRM_CLIENT_H_ |
---|
5 | 5 | |
---|
| 6 | +#include <linux/lockdep.h> |
---|
| 7 | +#include <linux/mutex.h> |
---|
6 | 8 | #include <linux/types.h> |
---|
| 9 | + |
---|
| 10 | +#include <drm/drm_connector.h> |
---|
| 11 | +#include <drm/drm_crtc.h> |
---|
7 | 12 | |
---|
8 | 13 | struct drm_client_dev; |
---|
9 | 14 | struct drm_device; |
---|
.. | .. |
---|
26 | 31 | * @unregister: |
---|
27 | 32 | * |
---|
28 | 33 | * Called when &drm_device is unregistered. The client should respond by |
---|
29 | | - * releasing it's resources using drm_client_release(). |
---|
| 34 | + * releasing its resources using drm_client_release(). |
---|
30 | 35 | * |
---|
31 | 36 | * This callback is optional. |
---|
32 | 37 | */ |
---|
.. | .. |
---|
38 | 43 | * Called on drm_lastclose(). The first client instance in the list that |
---|
39 | 44 | * returns zero gets the privilege to restore and no more clients are |
---|
40 | 45 | * called. This callback is not called after @unregister has been called. |
---|
| 46 | + * |
---|
| 47 | + * Note that the core does not guarantee exclusion against concurrent |
---|
| 48 | + * drm_open(). Clients need to ensure this themselves, for example by |
---|
| 49 | + * using drm_master_internal_acquire() and |
---|
| 50 | + * drm_master_internal_release(). |
---|
41 | 51 | * |
---|
42 | 52 | * This callback is optional. |
---|
43 | 53 | */ |
---|
.. | .. |
---|
85 | 95 | * @file: DRM file |
---|
86 | 96 | */ |
---|
87 | 97 | struct drm_file *file; |
---|
| 98 | + |
---|
| 99 | + /** |
---|
| 100 | + * @modeset_mutex: Protects @modesets. |
---|
| 101 | + */ |
---|
| 102 | + struct mutex modeset_mutex; |
---|
| 103 | + |
---|
| 104 | + /** |
---|
| 105 | + * @modesets: CRTC configurations |
---|
| 106 | + */ |
---|
| 107 | + struct drm_mode_set *modesets; |
---|
88 | 108 | }; |
---|
89 | 109 | |
---|
90 | 110 | int drm_client_init(struct drm_device *dev, struct drm_client_dev *client, |
---|
91 | 111 | const char *name, const struct drm_client_funcs *funcs); |
---|
92 | 112 | void drm_client_release(struct drm_client_dev *client); |
---|
93 | | -void drm_client_add(struct drm_client_dev *client); |
---|
| 113 | +void drm_client_register(struct drm_client_dev *client); |
---|
94 | 114 | |
---|
95 | 115 | void drm_client_dev_unregister(struct drm_device *dev); |
---|
96 | 116 | void drm_client_dev_hotplug(struct drm_device *dev); |
---|
.. | .. |
---|
134 | 154 | struct drm_client_buffer * |
---|
135 | 155 | drm_client_framebuffer_create(struct drm_client_dev *client, u32 width, u32 height, u32 format); |
---|
136 | 156 | void drm_client_framebuffer_delete(struct drm_client_buffer *buffer); |
---|
| 157 | +int drm_client_framebuffer_flush(struct drm_client_buffer *buffer, struct drm_rect *rect); |
---|
| 158 | +void *drm_client_buffer_vmap(struct drm_client_buffer *buffer); |
---|
| 159 | +void drm_client_buffer_vunmap(struct drm_client_buffer *buffer); |
---|
137 | 160 | |
---|
138 | | -int drm_client_debugfs_init(struct drm_minor *minor); |
---|
| 161 | +int drm_client_modeset_create(struct drm_client_dev *client); |
---|
| 162 | +void drm_client_modeset_free(struct drm_client_dev *client); |
---|
| 163 | +int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width, unsigned int height); |
---|
| 164 | +bool drm_client_rotation(struct drm_mode_set *modeset, unsigned int *rotation); |
---|
| 165 | +int drm_client_modeset_check(struct drm_client_dev *client); |
---|
| 166 | +int drm_client_modeset_commit_locked(struct drm_client_dev *client); |
---|
| 167 | +int drm_client_modeset_commit(struct drm_client_dev *client); |
---|
| 168 | +int drm_client_modeset_dpms(struct drm_client_dev *client, int mode); |
---|
| 169 | + |
---|
| 170 | +/** |
---|
| 171 | + * drm_client_for_each_modeset() - Iterate over client modesets |
---|
| 172 | + * @modeset: &drm_mode_set loop cursor |
---|
| 173 | + * @client: DRM client |
---|
| 174 | + */ |
---|
| 175 | +#define drm_client_for_each_modeset(modeset, client) \ |
---|
| 176 | + for (({ lockdep_assert_held(&(client)->modeset_mutex); }), \ |
---|
| 177 | + modeset = (client)->modesets; modeset->crtc; modeset++) |
---|
| 178 | + |
---|
| 179 | +/** |
---|
| 180 | + * drm_client_for_each_connector_iter - connector_list iterator macro |
---|
| 181 | + * @connector: &struct drm_connector pointer used as cursor |
---|
| 182 | + * @iter: &struct drm_connector_list_iter |
---|
| 183 | + * |
---|
| 184 | + * This iterates the connectors that are useable for internal clients (excludes |
---|
| 185 | + * writeback connectors). |
---|
| 186 | + * |
---|
| 187 | + * For more info see drm_for_each_connector_iter(). |
---|
| 188 | + */ |
---|
| 189 | +#define drm_client_for_each_connector_iter(connector, iter) \ |
---|
| 190 | + drm_for_each_connector_iter(connector, iter) \ |
---|
| 191 | + if (connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK) |
---|
| 192 | + |
---|
| 193 | +void drm_client_debugfs_init(struct drm_minor *minor); |
---|
139 | 194 | |
---|
140 | 195 | #endif |
---|