drm: Make drm_crtc_helper.h standalone includible
[deliverable/linux.git] / include / drm / drm_crtc_helper.h
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 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26 /*
27 * The DRM mode setting helper functions are common code for drivers to use if
28 * they wish. Drivers are not forced to use this code in their
29 * implementations but it would be useful if they code they do use at least
30 * provides a consistent interface and operation to userspace
31 */
32
33 #ifndef __DRM_CRTC_HELPER_H__
34 #define __DRM_CRTC_HELPER_H__
35
36 #include <linux/spinlock.h>
37 #include <linux/types.h>
38 #include <linux/idr.h>
39
40 #include <linux/fb.h>
41
42 #include <drm/drm_crtc.h>
43
44 enum mode_set_atomic {
45 LEAVE_ATOMIC_MODE_SET,
46 ENTER_ATOMIC_MODE_SET,
47 };
48
49 /**
50 * drm_crtc_helper_funcs - helper operations for CRTCs
51 * @mode_fixup: try to fixup proposed mode for this connector
52 * @mode_set: set this mode
53 *
54 * The helper operations are called by the mid-layer CRTC helper.
55 */
56 struct drm_crtc_helper_funcs {
57 /*
58 * Control power levels on the CRTC. If the mode passed in is
59 * unsupported, the provider must use the next lowest power level.
60 */
61 void (*dpms)(struct drm_crtc *crtc, int mode);
62 void (*prepare)(struct drm_crtc *crtc);
63 void (*commit)(struct drm_crtc *crtc);
64
65 /* Provider can fixup or change mode timings before modeset occurs */
66 bool (*mode_fixup)(struct drm_crtc *crtc,
67 const struct drm_display_mode *mode,
68 struct drm_display_mode *adjusted_mode);
69 /* Actually set the mode */
70 int (*mode_set)(struct drm_crtc *crtc, struct drm_display_mode *mode,
71 struct drm_display_mode *adjusted_mode, int x, int y,
72 struct drm_framebuffer *old_fb);
73 void (*mode_set_nofb)(struct drm_crtc *crtc);
74
75 /* Move the crtc on the current fb to the given position *optional* */
76 int (*mode_set_base)(struct drm_crtc *crtc, int x, int y,
77 struct drm_framebuffer *old_fb);
78 int (*mode_set_base_atomic)(struct drm_crtc *crtc,
79 struct drm_framebuffer *fb, int x, int y,
80 enum mode_set_atomic);
81
82 /* reload the current crtc LUT */
83 void (*load_lut)(struct drm_crtc *crtc);
84
85 /* disable crtc when not in use - more explicit than dpms off */
86 void (*disable)(struct drm_crtc *crtc);
87
88 /* atomic helpers */
89 int (*atomic_check)(struct drm_crtc *crtc,
90 struct drm_crtc_state *state);
91 void (*atomic_begin)(struct drm_crtc *crtc);
92 void (*atomic_flush)(struct drm_crtc *crtc);
93 };
94
95 /**
96 * drm_encoder_helper_funcs - helper operations for encoders
97 * @mode_fixup: try to fixup proposed mode for this connector
98 * @mode_set: set this mode
99 *
100 * The helper operations are called by the mid-layer CRTC helper.
101 */
102 struct drm_encoder_helper_funcs {
103 void (*dpms)(struct drm_encoder *encoder, int mode);
104 void (*save)(struct drm_encoder *encoder);
105 void (*restore)(struct drm_encoder *encoder);
106
107 bool (*mode_fixup)(struct drm_encoder *encoder,
108 const struct drm_display_mode *mode,
109 struct drm_display_mode *adjusted_mode);
110 void (*prepare)(struct drm_encoder *encoder);
111 void (*commit)(struct drm_encoder *encoder);
112 void (*mode_set)(struct drm_encoder *encoder,
113 struct drm_display_mode *mode,
114 struct drm_display_mode *adjusted_mode);
115 struct drm_crtc *(*get_crtc)(struct drm_encoder *encoder);
116 /* detect for DAC style encoders */
117 enum drm_connector_status (*detect)(struct drm_encoder *encoder,
118 struct drm_connector *connector);
119 /* disable encoder when not in use - more explicit than dpms off */
120 void (*disable)(struct drm_encoder *encoder);
121 };
122
123 /**
124 * drm_connector_helper_funcs - helper operations for connectors
125 * @get_modes: get mode list for this connector
126 * @mode_valid (optional): is this mode valid on the given connector?
127 *
128 * The helper operations are called by the mid-layer CRTC helper.
129 */
130 struct drm_connector_helper_funcs {
131 int (*get_modes)(struct drm_connector *connector);
132 enum drm_mode_status (*mode_valid)(struct drm_connector *connector,
133 struct drm_display_mode *mode);
134 struct drm_encoder *(*best_encoder)(struct drm_connector *connector);
135 };
136
137 extern void drm_helper_disable_unused_functions(struct drm_device *dev);
138 extern int drm_crtc_helper_set_config(struct drm_mode_set *set);
139 extern bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
140 struct drm_display_mode *mode,
141 int x, int y,
142 struct drm_framebuffer *old_fb);
143 extern bool drm_helper_crtc_in_use(struct drm_crtc *crtc);
144 extern bool drm_helper_encoder_in_use(struct drm_encoder *encoder);
145
146 extern void drm_helper_connector_dpms(struct drm_connector *connector, int mode);
147
148 extern void drm_helper_move_panel_connectors_to_head(struct drm_device *);
149
150 extern void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
151 struct drm_mode_fb_cmd2 *mode_cmd);
152
153 static inline void drm_crtc_helper_add(struct drm_crtc *crtc,
154 const struct drm_crtc_helper_funcs *funcs)
155 {
156 crtc->helper_private = (void *)funcs;
157 }
158
159 static inline void drm_encoder_helper_add(struct drm_encoder *encoder,
160 const struct drm_encoder_helper_funcs *funcs)
161 {
162 encoder->helper_private = (void *)funcs;
163 }
164
165 static inline void drm_connector_helper_add(struct drm_connector *connector,
166 const struct drm_connector_helper_funcs *funcs)
167 {
168 connector->helper_private = (void *)funcs;
169 }
170
171 extern void drm_helper_resume_force_mode(struct drm_device *dev);
172
173 int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
174 struct drm_display_mode *adjusted_mode, int x, int y,
175 struct drm_framebuffer *old_fb);
176 int drm_helper_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
177 struct drm_framebuffer *old_fb);
178
179 /* drm_probe_helper.c */
180 extern int drm_helper_probe_single_connector_modes(struct drm_connector
181 *connector, uint32_t maxX,
182 uint32_t maxY);
183 extern int drm_helper_probe_single_connector_modes_nomerge(struct drm_connector
184 *connector,
185 uint32_t maxX,
186 uint32_t maxY);
187 extern void drm_kms_helper_poll_init(struct drm_device *dev);
188 extern void drm_kms_helper_poll_fini(struct drm_device *dev);
189 extern bool drm_helper_hpd_irq_event(struct drm_device *dev);
190 extern void drm_kms_helper_hotplug_event(struct drm_device *dev);
191
192 extern void drm_kms_helper_poll_disable(struct drm_device *dev);
193 extern void drm_kms_helper_poll_enable(struct drm_device *dev);
194
195 #endif
This page took 0.035103 seconds and 5 git commands to generate.