Subversion Repositories Kolibri OS

Rev

Rev 5270 | Rev 6936 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1408 serge 1
/*
2
 * Copyright © 2006 Keith Packard
3
 * Copyright © 2007-2008 Dave Airlie
4
 * Copyright © 2007-2008 Intel Corporation
5
 *   Jesse Barnes 
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
 
1630 serge 36
#include 
1408 serge 37
#include 
1428 serge 38
#include 
1408 serge 39
 
40
#include 
41
 
6082 serge 42
#include 
43
 
1964 serge 44
enum mode_set_atomic {
45
	LEAVE_ATOMIC_MODE_SET,
46
	ENTER_ATOMIC_MODE_SET,
47
};
48
 
3031 serge 49
/**
6082 serge 50
 * struct drm_crtc_helper_funcs - helper operations for CRTCs
51
 * @dpms: set power state
52
 * @prepare: prepare the CRTC, called before @mode_set
53
 * @commit: commit changes to CRTC, called after @mode_set
54
 * @mode_fixup: try to fixup proposed mode for this CRTC
3031 serge 55
 * @mode_set: set this mode
6082 serge 56
 * @mode_set_nofb: set mode only (no scanout buffer attached)
57
 * @mode_set_base: update the scanout buffer
58
 * @mode_set_base_atomic: non-blocking mode set (used for kgdb support)
59
 * @load_lut: load color palette
60
 * @disable: disable CRTC when no longer in use
61
 * @enable: enable CRTC
62
 * @atomic_check: check for validity of an atomic state
63
 * @atomic_begin: begin atomic update
64
 * @atomic_flush: flush atomic update
3031 serge 65
 *
66
 * The helper operations are called by the mid-layer CRTC helper.
6082 serge 67
 *
68
 * Note that with atomic helpers @dpms, @prepare and @commit hooks are
69
 * deprecated. Used @enable and @disable instead exclusively.
70
 *
71
 * With legacy crtc helpers there's a big semantic difference between @disable
72
 * and the other hooks: @disable also needs to release any resources acquired in
73
 * @mode_set (like shared PLLs).
3031 serge 74
 */
1408 serge 75
struct drm_crtc_helper_funcs {
76
	/*
77
	 * Control power levels on the CRTC.  If the mode passed in is
78
	 * unsupported, the provider must use the next lowest power level.
79
	 */
80
	void (*dpms)(struct drm_crtc *crtc, int mode);
81
	void (*prepare)(struct drm_crtc *crtc);
82
	void (*commit)(struct drm_crtc *crtc);
83
 
84
	/* Provider can fixup or change mode timings before modeset occurs */
85
	bool (*mode_fixup)(struct drm_crtc *crtc,
3031 serge 86
			   const struct drm_display_mode *mode,
1408 serge 87
			   struct drm_display_mode *adjusted_mode);
88
	/* Actually set the mode */
89
	int (*mode_set)(struct drm_crtc *crtc, struct drm_display_mode *mode,
90
			struct drm_display_mode *adjusted_mode, int x, int y,
91
			struct drm_framebuffer *old_fb);
6082 serge 92
	/* Actually set the mode for atomic helpers, optional */
5270 serge 93
	void (*mode_set_nofb)(struct drm_crtc *crtc);
1408 serge 94
 
95
	/* Move the crtc on the current fb to the given position *optional* */
96
	int (*mode_set_base)(struct drm_crtc *crtc, int x, int y,
97
			     struct drm_framebuffer *old_fb);
1964 serge 98
	int (*mode_set_base_atomic)(struct drm_crtc *crtc,
99
				    struct drm_framebuffer *fb, int x, int y,
100
				    enum mode_set_atomic);
1408 serge 101
 
102
	/* reload the current crtc LUT */
103
	void (*load_lut)(struct drm_crtc *crtc);
1964 serge 104
 
105
	void (*disable)(struct drm_crtc *crtc);
6082 serge 106
	void (*enable)(struct drm_crtc *crtc);
5270 serge 107
 
108
	/* atomic helpers */
109
	int (*atomic_check)(struct drm_crtc *crtc,
110
			    struct drm_crtc_state *state);
6082 serge 111
	void (*atomic_begin)(struct drm_crtc *crtc,
112
			     struct drm_crtc_state *old_crtc_state);
113
	void (*atomic_flush)(struct drm_crtc *crtc,
114
			     struct drm_crtc_state *old_crtc_state);
1408 serge 115
};
116
 
3031 serge 117
/**
6082 serge 118
 * struct drm_encoder_helper_funcs - helper operations for encoders
119
 * @dpms: set power state
120
 * @save: save connector state
121
 * @restore: restore connector state
3031 serge 122
 * @mode_fixup: try to fixup proposed mode for this connector
6082 serge 123
 * @prepare: part of the disable sequence, called before the CRTC modeset
124
 * @commit: called after the CRTC modeset
125
 * @mode_set: set this mode, optional for atomic helpers
126
 * @get_crtc: return CRTC that the encoder is currently attached to
127
 * @detect: connection status detection
128
 * @disable: disable encoder when not in use (overrides DPMS off)
129
 * @enable: enable encoder
130
 * @atomic_check: check for validity of an atomic update
3031 serge 131
 *
132
 * The helper operations are called by the mid-layer CRTC helper.
6082 serge 133
 *
134
 * Note that with atomic helpers @dpms, @prepare and @commit hooks are
135
 * deprecated. Used @enable and @disable instead exclusively.
136
 *
137
 * With legacy crtc helpers there's a big semantic difference between @disable
138
 * and the other hooks: @disable also needs to release any resources acquired in
139
 * @mode_set (like shared PLLs).
3031 serge 140
 */
1408 serge 141
struct drm_encoder_helper_funcs {
142
	void (*dpms)(struct drm_encoder *encoder, int mode);
143
	void (*save)(struct drm_encoder *encoder);
144
	void (*restore)(struct drm_encoder *encoder);
145
 
146
	bool (*mode_fixup)(struct drm_encoder *encoder,
3031 serge 147
			   const struct drm_display_mode *mode,
1408 serge 148
			   struct drm_display_mode *adjusted_mode);
149
	void (*prepare)(struct drm_encoder *encoder);
150
	void (*commit)(struct drm_encoder *encoder);
151
	void (*mode_set)(struct drm_encoder *encoder,
152
			 struct drm_display_mode *mode,
153
			 struct drm_display_mode *adjusted_mode);
154
	struct drm_crtc *(*get_crtc)(struct drm_encoder *encoder);
155
	/* detect for DAC style encoders */
156
	enum drm_connector_status (*detect)(struct drm_encoder *encoder,
157
					    struct drm_connector *connector);
158
	void (*disable)(struct drm_encoder *encoder);
6082 serge 159
 
160
	void (*enable)(struct drm_encoder *encoder);
161
 
162
	/* atomic helpers */
163
	int (*atomic_check)(struct drm_encoder *encoder,
164
			    struct drm_crtc_state *crtc_state,
165
			    struct drm_connector_state *conn_state);
1408 serge 166
};
167
 
3031 serge 168
/**
6082 serge 169
 * struct drm_connector_helper_funcs - helper operations for connectors
3031 serge 170
 * @get_modes: get mode list for this connector
6082 serge 171
 * @mode_valid: is this mode valid on the given connector? (optional)
172
 * @best_encoder: return the preferred encoder for this connector
173
 * @atomic_best_encoder: atomic version of @best_encoder
3031 serge 174
 *
175
 * The helper operations are called by the mid-layer CRTC helper.
176
 */
1408 serge 177
struct drm_connector_helper_funcs {
178
	int (*get_modes)(struct drm_connector *connector);
4559 Serge 179
	enum drm_mode_status (*mode_valid)(struct drm_connector *connector,
6082 serge 180
					   struct drm_display_mode *mode);
1408 serge 181
	struct drm_encoder *(*best_encoder)(struct drm_connector *connector);
6082 serge 182
	struct drm_encoder *(*atomic_best_encoder)(struct drm_connector *connector,
183
						   struct drm_connector_state *connector_state);
1408 serge 184
};
185
 
186
extern void drm_helper_disable_unused_functions(struct drm_device *dev);
187
extern int drm_crtc_helper_set_config(struct drm_mode_set *set);
188
extern bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
189
				     struct drm_display_mode *mode,
190
				     int x, int y,
191
				     struct drm_framebuffer *old_fb);
192
extern bool drm_helper_crtc_in_use(struct drm_crtc *crtc);
193
extern bool drm_helper_encoder_in_use(struct drm_encoder *encoder);
194
 
6082 serge 195
extern int drm_helper_connector_dpms(struct drm_connector *connector, int mode);
1408 serge 196
 
3192 Serge 197
extern void drm_helper_move_panel_connectors_to_head(struct drm_device *);
198
 
5056 serge 199
extern void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
6082 serge 200
					   struct drm_mode_fb_cmd2 *mode_cmd);
1408 serge 201
 
202
static inline void drm_crtc_helper_add(struct drm_crtc *crtc,
203
				       const struct drm_crtc_helper_funcs *funcs)
204
{
6082 serge 205
	crtc->helper_private = funcs;
1408 serge 206
}
207
 
208
static inline void drm_encoder_helper_add(struct drm_encoder *encoder,
209
					  const struct drm_encoder_helper_funcs *funcs)
210
{
6082 serge 211
	encoder->helper_private = funcs;
1408 serge 212
}
213
 
1964 serge 214
static inline void drm_connector_helper_add(struct drm_connector *connector,
1408 serge 215
					    const struct drm_connector_helper_funcs *funcs)
216
{
6082 serge 217
	connector->helper_private = funcs;
1408 serge 218
}
219
 
5056 serge 220
extern void drm_helper_resume_force_mode(struct drm_device *dev);
221
 
5270 serge 222
int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
223
			     struct drm_display_mode *adjusted_mode, int x, int y,
224
			     struct drm_framebuffer *old_fb);
225
int drm_helper_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
226
				  struct drm_framebuffer *old_fb);
227
 
5056 serge 228
/* drm_probe_helper.c */
229
extern int drm_helper_probe_single_connector_modes(struct drm_connector
230
						   *connector, uint32_t maxX,
231
						   uint32_t maxY);
232
extern int drm_helper_probe_single_connector_modes_nomerge(struct drm_connector
233
							   *connector,
234
							   uint32_t maxX,
235
							   uint32_t maxY);
1964 serge 236
extern void drm_kms_helper_poll_init(struct drm_device *dev);
237
extern void drm_kms_helper_poll_fini(struct drm_device *dev);
4559 Serge 238
extern bool drm_helper_hpd_irq_event(struct drm_device *dev);
3192 Serge 239
extern void drm_kms_helper_hotplug_event(struct drm_device *dev);
1964 serge 240
 
241
extern void drm_kms_helper_poll_disable(struct drm_device *dev);
242
extern void drm_kms_helper_poll_enable(struct drm_device *dev);
6082 serge 243
extern void drm_kms_helper_poll_enable_locked(struct drm_device *dev);
2967 Serge 244
 
1408 serge 245
#endif