]>
Commit | Line | Data |
---|---|---|
a8f8b1d9 DV |
1 | /* |
2 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. | |
3 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. | |
4 | * Copyright (c) 2009-2010, Code Aurora Forum. | |
5 | * All rights reserved. | |
6 | * | |
7 | * Author: Rickard E. (Rik) Faith <faith@valinux.com> | |
8 | * Author: Gareth Hughes <gareth@valinux.com> | |
9 | * | |
10 | * Permission is hereby granted, free of charge, to any person obtaining a | |
11 | * copy of this software and associated documentation files (the "Software"), | |
12 | * to deal in the Software without restriction, including without limitation | |
13 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
14 | * and/or sell copies of the Software, and to permit persons to whom the | |
15 | * Software is furnished to do so, subject to the following conditions: | |
16 | * | |
17 | * The above copyright notice and this permission notice (including the next | |
18 | * paragraph) shall be included in all copies or substantial portions of the | |
19 | * Software. | |
20 | * | |
21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
24 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR | |
25 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | |
26 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |
27 | * OTHER DEALINGS IN THE SOFTWARE. | |
28 | */ | |
29 | ||
30 | #ifndef _DRM_FILE_H_ | |
31 | #define _DRM_FILE_H_ | |
32 | ||
33 | #include <linux/types.h> | |
34 | #include <linux/completion.h> | |
35 | ||
36 | #include <uapi/drm/drm.h> | |
37 | ||
38 | #include <drm/drm_prime.h> | |
39 | ||
40 | struct dma_fence; | |
41 | struct drm_file; | |
42 | struct drm_device; | |
43 | ||
44 | /* | |
45 | * FIXME: Not sure we want to have drm_minor here in the end, but to avoid | |
46 | * header include loops we need it here for now. | |
47 | */ | |
48 | enum drm_minor_type { | |
49 | DRM_MINOR_PRIMARY, | |
50 | DRM_MINOR_CONTROL, | |
51 | DRM_MINOR_RENDER, | |
52 | }; | |
53 | ||
54 | /** | |
55 | * DRM minor structure. This structure represents a drm minor number. | |
56 | */ | |
57 | struct drm_minor { | |
58 | int index; /**< Minor device number */ | |
59 | int type; /**< Control or render */ | |
60 | struct device *kdev; /**< Linux device */ | |
61 | struct drm_device *dev; | |
62 | ||
63 | struct dentry *debugfs_root; | |
64 | ||
65 | struct list_head debugfs_list; | |
66 | struct mutex debugfs_lock; /* Protects debugfs_list. */ | |
67 | }; | |
68 | ||
69 | /* Event queued up for userspace to read */ | |
70 | struct drm_pending_event { | |
71 | struct completion *completion; | |
72 | void (*completion_release)(struct completion *completion); | |
73 | struct drm_event *event; | |
74 | struct dma_fence *fence; | |
75 | struct list_head link; | |
76 | struct list_head pending_link; | |
77 | struct drm_file *file_priv; | |
78 | pid_t pid; /* pid of requester, no guarantee it's valid by the time | |
79 | we deliver the event, for tracing only */ | |
80 | }; | |
81 | ||
82 | /** File private data */ | |
83 | struct drm_file { | |
84 | unsigned authenticated :1; | |
85 | /* true when the client has asked us to expose stereo 3D mode flags */ | |
86 | unsigned stereo_allowed :1; | |
87 | /* | |
88 | * true if client understands CRTC primary planes and cursor planes | |
89 | * in the plane list | |
90 | */ | |
91 | unsigned universal_planes:1; | |
92 | /* true if client understands atomic properties */ | |
93 | unsigned atomic:1; | |
94 | /* | |
95 | * This client is the creator of @master. | |
96 | * Protected by struct drm_device::master_mutex. | |
97 | */ | |
98 | unsigned is_master:1; | |
99 | ||
100 | struct pid *pid; | |
101 | drm_magic_t magic; | |
102 | struct list_head lhead; | |
103 | struct drm_minor *minor; | |
104 | unsigned long lock_count; | |
105 | ||
106 | /** Mapping of mm object handles to object pointers. */ | |
107 | struct idr object_idr; | |
108 | /** Lock for synchronization of access to object_idr. */ | |
109 | spinlock_t table_lock; | |
110 | ||
111 | struct file *filp; | |
112 | void *driver_priv; | |
113 | ||
114 | struct drm_master *master; /* master this node is currently associated with | |
115 | N.B. not always dev->master */ | |
116 | /** | |
117 | * fbs - List of framebuffers associated with this file. | |
118 | * | |
119 | * Protected by fbs_lock. Note that the fbs list holds a reference on | |
120 | * the fb object to prevent it from untimely disappearing. | |
121 | */ | |
122 | struct list_head fbs; | |
123 | struct mutex fbs_lock; | |
124 | ||
125 | /** User-created blob properties; this retains a reference on the | |
126 | * property. */ | |
127 | struct list_head blobs; | |
128 | ||
129 | wait_queue_head_t event_wait; | |
130 | struct list_head pending_event_list; | |
131 | struct list_head event_list; | |
132 | int event_space; | |
133 | ||
134 | struct mutex event_read_lock; | |
135 | ||
136 | struct drm_prime_file_private prime; | |
137 | }; | |
138 | ||
139 | static inline bool drm_is_render_client(const struct drm_file *file_priv) | |
140 | { | |
141 | return file_priv->minor->type == DRM_MINOR_RENDER; | |
142 | } | |
143 | ||
144 | static inline bool drm_is_control_client(const struct drm_file *file_priv) | |
145 | { | |
146 | return file_priv->minor->type == DRM_MINOR_CONTROL; | |
147 | } | |
148 | ||
149 | static inline bool drm_is_primary_client(const struct drm_file *file_priv) | |
150 | { | |
151 | return file_priv->minor->type == DRM_MINOR_PRIMARY; | |
152 | } | |
153 | ||
154 | int drm_open(struct inode *inode, struct file *filp); | |
155 | ssize_t drm_read(struct file *filp, char __user *buffer, | |
156 | size_t count, loff_t *offset); | |
157 | int drm_release(struct inode *inode, struct file *filp); | |
158 | unsigned int drm_poll(struct file *filp, struct poll_table_struct *wait); | |
159 | int drm_event_reserve_init_locked(struct drm_device *dev, | |
160 | struct drm_file *file_priv, | |
161 | struct drm_pending_event *p, | |
162 | struct drm_event *e); | |
163 | int drm_event_reserve_init(struct drm_device *dev, | |
164 | struct drm_file *file_priv, | |
165 | struct drm_pending_event *p, | |
166 | struct drm_event *e); | |
167 | void drm_event_cancel_free(struct drm_device *dev, | |
168 | struct drm_pending_event *p); | |
169 | void drm_send_event_locked(struct drm_device *dev, struct drm_pending_event *e); | |
170 | void drm_send_event(struct drm_device *dev, struct drm_pending_event *e); | |
171 | ||
172 | #endif /* _DRM_FILE_H_ */ |