1 /*
2  * Copyright © 2006 Keith Packard
3  * Copyright © 2007-2008 Dave Airlie
4  * Copyright © 2007-2008 Intel Corporation
5  *   Jesse Barnes <jesse.barnes@intel.com>
6  * Copyright © 2014 Intel Corporation
7  *   Daniel Vetter <daniel.vetter@ffwll.ch>
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a
10  * copy of this software and associated documentation files (the "Software"),
11  * to deal in the Software without restriction, including without limitation
12  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13  * and/or sell copies of the Software, and to permit persons to whom the
14  * Software is furnished to do so, subject to the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be included in
17  * all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
22  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  */
27 
28 /*
29  * This header file contains mode setting related functions and definitions
30  * which are only used within the drm module as internal implementation details
31  * and are not exported to drivers.
32  */
33 
34 #include <linux/types.h>
35 
36 enum drm_color_encoding;
37 enum drm_color_range;
38 enum drm_connector_force;
39 enum drm_mode_status;
40 
41 struct drm_atomic_state;
42 struct drm_bridge;
43 struct drm_connector;
44 struct drm_crtc;
45 struct drm_device;
46 struct drm_display_mode;
47 struct drm_file;
48 struct drm_framebuffer;
49 struct drm_mode_create_dumb;
50 struct drm_mode_fb_cmd2;
51 struct drm_mode_fb_cmd;
52 struct drm_mode_object;
53 struct drm_mode_set;
54 struct drm_plane;
55 struct drm_plane_state;
56 struct drm_property;
57 struct edid;
58 struct kref;
59 struct work_struct;
60 
61 /* drm_crtc.c */
62 int drm_mode_crtc_set_obj_prop(struct drm_mode_object *obj,
63 			       struct drm_property *property,
64 			       uint64_t value);
65 int drm_crtc_check_viewport(const struct drm_crtc *crtc,
66 			    int x, int y,
67 			    const struct drm_display_mode *mode,
68 			    const struct drm_framebuffer *fb);
69 int drm_crtc_register_all(struct drm_device *dev);
70 void drm_crtc_unregister_all(struct drm_device *dev);
71 int drm_crtc_force_disable(struct drm_crtc *crtc);
72 
73 struct dma_fence *drm_crtc_create_fence(struct drm_crtc *crtc);
74 
75 struct drm_property *
76 drm_create_scaling_filter_prop(struct drm_device *dev,
77 			       unsigned int supported_filters);
78 /* IOCTLs */
79 int drm_mode_getcrtc(struct drm_device *dev,
80 		     void *data, struct drm_file *file_priv);
81 int drm_mode_setcrtc(struct drm_device *dev,
82 		     void *data, struct drm_file *file_priv);
83 
84 
85 /* drm_mode_config.c */
86 int drm_modeset_register_all(struct drm_device *dev);
87 void drm_modeset_unregister_all(struct drm_device *dev);
88 void drm_mode_config_validate(struct drm_device *dev);
89 
90 /* drm_modes.c */
91 const char *drm_get_mode_status_name(enum drm_mode_status status);
92 
93 /* IOCTLs */
94 int drm_mode_getresources(struct drm_device *dev,
95 			  void *data, struct drm_file *file_priv);
96 
97 
98 /* drm_dumb_buffers.c */
99 int drm_mode_create_dumb(struct drm_device *dev,
100 			 struct drm_mode_create_dumb *args,
101 			 struct drm_file *file_priv);
102 int drm_mode_destroy_dumb(struct drm_device *dev, u32 handle,
103 			  struct drm_file *file_priv);
104 
105 /* IOCTLs */
106 int drm_mode_create_dumb_ioctl(struct drm_device *dev,
107 			       void *data, struct drm_file *file_priv);
108 int drm_mode_mmap_dumb_ioctl(struct drm_device *dev,
109 			     void *data, struct drm_file *file_priv);
110 int drm_mode_destroy_dumb_ioctl(struct drm_device *dev,
111 				void *data, struct drm_file *file_priv);
112 
113 /* drm_color_mgmt.c */
114 const char *drm_get_color_encoding_name(enum drm_color_encoding encoding);
115 const char *drm_get_color_range_name(enum drm_color_range range);
116 
117 /* IOCTLs */
118 int drm_mode_gamma_get_ioctl(struct drm_device *dev,
119 			     void *data, struct drm_file *file_priv);
120 int drm_mode_gamma_set_ioctl(struct drm_device *dev,
121 			     void *data, struct drm_file *file_priv);
122 
123 /* drm_property.c */
124 void drm_property_destroy_user_blobs(struct drm_device *dev,
125 				     struct drm_file *file_priv);
126 bool drm_property_change_valid_get(struct drm_property *property,
127 				   uint64_t value,
128 				   struct drm_mode_object **ref);
129 void drm_property_change_valid_put(struct drm_property *property,
130 				   struct drm_mode_object *ref);
131 
132 /* IOCTL */
133 int drm_mode_getproperty_ioctl(struct drm_device *dev,
134 			       void *data, struct drm_file *file_priv);
135 int drm_mode_getblob_ioctl(struct drm_device *dev,
136 			   void *data, struct drm_file *file_priv);
137 int drm_mode_createblob_ioctl(struct drm_device *dev,
138 			      void *data, struct drm_file *file_priv);
139 int drm_mode_destroyblob_ioctl(struct drm_device *dev,
140 			       void *data, struct drm_file *file_priv);
141 
142 /* drm_mode_object.c */
143 int __drm_mode_object_add(struct drm_device *dev, struct drm_mode_object *obj,
144 			  uint32_t obj_type, bool register_obj,
145 			  void (*obj_free_cb)(struct kref *kref));
146 int drm_mode_object_add(struct drm_device *dev, struct drm_mode_object *obj,
147 			uint32_t obj_type);
148 void drm_mode_object_register(struct drm_device *dev,
149 			      struct drm_mode_object *obj);
150 struct drm_mode_object *__drm_mode_object_find(struct drm_device *dev,
151 					       struct drm_file *file_priv,
152 					       uint32_t id, uint32_t type);
153 void drm_mode_object_unregister(struct drm_device *dev,
154 				struct drm_mode_object *object);
155 int drm_mode_object_get_properties(struct drm_mode_object *obj, bool atomic,
156 				   uint32_t __user *prop_ptr,
157 				   uint64_t __user *prop_values,
158 				   uint32_t *arg_count_props);
159 struct drm_property *drm_mode_obj_find_prop_id(struct drm_mode_object *obj,
160 					       uint32_t prop_id);
161 
162 /* IOCTL */
163 
164 int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data,
165 				      struct drm_file *file_priv);
166 int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data,
167 				    struct drm_file *file_priv);
168 
169 /* drm_encoder.c */
170 int drm_encoder_register_all(struct drm_device *dev);
171 void drm_encoder_unregister_all(struct drm_device *dev);
172 
173 /* IOCTL */
174 int drm_mode_getencoder(struct drm_device *dev,
175 			void *data, struct drm_file *file_priv);
176 
177 /* drm_connector.c */
178 void drm_connector_ida_init(void);
179 void drm_connector_ida_destroy(void);
180 void drm_connector_unregister_all(struct drm_device *dev);
181 int drm_connector_register_all(struct drm_device *dev);
182 int drm_connector_set_obj_prop(struct drm_mode_object *obj,
183 				    struct drm_property *property,
184 				    uint64_t value);
185 int drm_connector_create_standard_properties(struct drm_device *dev);
186 const char *drm_get_connector_force_name(enum drm_connector_force force);
187 void drm_connector_free_work_fn(struct work_struct *work);
188 
189 /* IOCTL */
190 int drm_connector_property_set_ioctl(struct drm_device *dev,
191 				     void *data, struct drm_file *file_priv);
192 int drm_mode_getconnector(struct drm_device *dev,
193 			  void *data, struct drm_file *file_priv);
194 
195 /* drm_framebuffer.c */
196 struct drm_framebuffer *
197 drm_internal_framebuffer_create(struct drm_device *dev,
198 				const struct drm_mode_fb_cmd2 *r,
199 				struct drm_file *file_priv);
200 void drm_framebuffer_free(struct kref *kref);
201 int drm_framebuffer_check_src_coords(uint32_t src_x, uint32_t src_y,
202 				     uint32_t src_w, uint32_t src_h,
203 				     const struct drm_framebuffer *fb);
204 void drm_fb_release(struct drm_file *file_priv);
205 
206 int drm_mode_addfb(struct drm_device *dev, struct drm_mode_fb_cmd *or,
207 		   struct drm_file *file_priv);
208 int drm_mode_addfb2(struct drm_device *dev,
209 		    void *data, struct drm_file *file_priv);
210 int drm_mode_rmfb(struct drm_device *dev, u32 fb_id,
211 		  struct drm_file *file_priv);
212 
213 
214 /* IOCTL */
215 int drm_mode_addfb_ioctl(struct drm_device *dev,
216 			 void *data, struct drm_file *file_priv);
217 int drm_mode_addfb2_ioctl(struct drm_device *dev,
218 			  void *data, struct drm_file *file_priv);
219 int drm_mode_rmfb_ioctl(struct drm_device *dev,
220 			void *data, struct drm_file *file_priv);
221 int drm_mode_getfb(struct drm_device *dev,
222 		   void *data, struct drm_file *file_priv);
223 int drm_mode_getfb2_ioctl(struct drm_device *dev,
224 			  void *data, struct drm_file *file_priv);
225 int drm_mode_dirtyfb_ioctl(struct drm_device *dev,
226 			   void *data, struct drm_file *file_priv);
227 
228 /* drm_atomic.c */
229 #ifdef CONFIG_DEBUG_FS
230 struct drm_minor;
231 void drm_atomic_debugfs_init(struct drm_minor *minor);
232 #endif
233 
234 int __drm_atomic_helper_disable_plane(struct drm_plane *plane,
235 				      struct drm_plane_state *plane_state);
236 int __drm_atomic_helper_set_config(struct drm_mode_set *set,
237 				   struct drm_atomic_state *state);
238 
239 void drm_atomic_print_state(const struct drm_atomic_state *state);
240 
241 /* drm_atomic_uapi.c */
242 int drm_atomic_connector_commit_dpms(struct drm_atomic_state *state,
243 				     struct drm_connector *connector,
244 				     int mode);
245 int drm_atomic_set_property(struct drm_atomic_state *state,
246 			    struct drm_file *file_priv,
247 			    struct drm_mode_object *obj,
248 			    struct drm_property *prop,
249 			    uint64_t prop_value);
250 int drm_atomic_get_property(struct drm_mode_object *obj,
251 			    struct drm_property *property, uint64_t *val);
252 
253 /* IOCTL */
254 int drm_mode_atomic_ioctl(struct drm_device *dev,
255 			  void *data, struct drm_file *file_priv);
256 
257 
258 /* drm_plane.c */
259 int drm_plane_register_all(struct drm_device *dev);
260 void drm_plane_unregister_all(struct drm_device *dev);
261 int drm_plane_check_pixel_format(struct drm_plane *plane,
262 				 u32 format, u64 modifier);
263 
264 /* drm_bridge.c */
265 void drm_bridge_detach(struct drm_bridge *bridge);
266 
267 /* IOCTL */
268 int drm_mode_getplane_res(struct drm_device *dev, void *data,
269 			  struct drm_file *file_priv);
270 int drm_mode_getplane(struct drm_device *dev,
271 		      void *data, struct drm_file *file_priv);
272 int drm_mode_setplane(struct drm_device *dev,
273 		      void *data, struct drm_file *file_priv);
274 int drm_mode_cursor_ioctl(struct drm_device *dev,
275 			  void *data, struct drm_file *file_priv);
276 int drm_mode_cursor2_ioctl(struct drm_device *dev,
277 			   void *data, struct drm_file *file_priv);
278 int drm_mode_page_flip_ioctl(struct drm_device *dev,
279 			     void *data, struct drm_file *file_priv);
280 
281 /* drm_edid.c */
282 void drm_mode_fixup_1366x768(struct drm_display_mode *mode);
283 void drm_reset_display_info(struct drm_connector *connector);
284 u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edid);
285 void drm_update_tile_info(struct drm_connector *connector, const struct edid *edid);
286