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