Merge tag 'drm/tegra/for-3.20-rc1' of git://anongit.freedesktop.org/tegra/linux into...
[deliverable/linux.git] / include / drm / drm_crtc_helper.h
CommitLineData
f453ba04
DA
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
f453ba04
DA
36#include <linux/spinlock.h>
37#include <linux/types.h>
38#include <linux/idr.h>
39
40#include <linux/fb.h>
41
6d11a2f0
TR
42#include <drm/drm_crtc.h>
43
21c74a8e
JW
44enum mode_set_atomic {
45 LEAVE_ATOMIC_MODE_SET,
46 ENTER_ATOMIC_MODE_SET,
47};
48
3b02ab88 49/**
7552e7dd
TR
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
3b02ab88 55 * @mode_set: set this mode
7552e7dd
TR
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 * @atomic_check: check for validity of an atomic state
62 * @atomic_begin: begin atomic update
63 * @atomic_flush: flush atomic update
3b02ab88
LP
64 *
65 * The helper operations are called by the mid-layer CRTC helper.
66 */
f453ba04
DA
67struct drm_crtc_helper_funcs {
68 /*
69 * Control power levels on the CRTC. If the mode passed in is
70 * unsupported, the provider must use the next lowest power level.
71 */
72 void (*dpms)(struct drm_crtc *crtc, int mode);
73 void (*prepare)(struct drm_crtc *crtc);
74 void (*commit)(struct drm_crtc *crtc);
75
76 /* Provider can fixup or change mode timings before modeset occurs */
77 bool (*mode_fixup)(struct drm_crtc *crtc,
e811f5ae 78 const struct drm_display_mode *mode,
f453ba04
DA
79 struct drm_display_mode *adjusted_mode);
80 /* Actually set the mode */
5c3b82e2
CW
81 int (*mode_set)(struct drm_crtc *crtc, struct drm_display_mode *mode,
82 struct drm_display_mode *adjusted_mode, int x, int y,
83 struct drm_framebuffer *old_fb);
2f324b42 84 void (*mode_set_nofb)(struct drm_crtc *crtc);
f453ba04
DA
85
86 /* Move the crtc on the current fb to the given position *optional* */
5c3b82e2
CW
87 int (*mode_set_base)(struct drm_crtc *crtc, int x, int y,
88 struct drm_framebuffer *old_fb);
1a7aba7f 89 int (*mode_set_base_atomic)(struct drm_crtc *crtc,
413d45d3 90 struct drm_framebuffer *fb, int x, int y,
21c74a8e 91 enum mode_set_atomic);
068143d3
DA
92
93 /* reload the current crtc LUT */
94 void (*load_lut)(struct drm_crtc *crtc);
5c8d7171
AD
95
96 /* disable crtc when not in use - more explicit than dpms off */
97 void (*disable)(struct drm_crtc *crtc);
c2fcd274
DV
98
99 /* atomic helpers */
100 int (*atomic_check)(struct drm_crtc *crtc,
101 struct drm_crtc_state *state);
102 void (*atomic_begin)(struct drm_crtc *crtc);
103 void (*atomic_flush)(struct drm_crtc *crtc);
f453ba04
DA
104};
105
3b02ab88 106/**
7552e7dd
TR
107 * struct drm_encoder_helper_funcs - helper operations for encoders
108 * @dpms: set power state
109 * @save: save connector state
110 * @restore: restore connector state
3b02ab88 111 * @mode_fixup: try to fixup proposed mode for this connector
7552e7dd
TR
112 * @prepare: part of the disable sequence, called before the CRTC modeset
113 * @commit: called after the CRTC modeset
3b02ab88 114 * @mode_set: set this mode
7552e7dd
TR
115 * @get_crtc: return CRTC that the encoder is currently attached to
116 * @detect: connection status detection
117 * @disable: disable encoder when not in use (overrides DPMS off)
4cd4df80 118 * @atomic_check: check for validity of an atomic update
3b02ab88
LP
119 *
120 * The helper operations are called by the mid-layer CRTC helper.
121 */
f453ba04
DA
122struct drm_encoder_helper_funcs {
123 void (*dpms)(struct drm_encoder *encoder, int mode);
124 void (*save)(struct drm_encoder *encoder);
125 void (*restore)(struct drm_encoder *encoder);
126
127 bool (*mode_fixup)(struct drm_encoder *encoder,
e811f5ae 128 const struct drm_display_mode *mode,
f453ba04
DA
129 struct drm_display_mode *adjusted_mode);
130 void (*prepare)(struct drm_encoder *encoder);
131 void (*commit)(struct drm_encoder *encoder);
132 void (*mode_set)(struct drm_encoder *encoder,
133 struct drm_display_mode *mode,
134 struct drm_display_mode *adjusted_mode);
7bec756c 135 struct drm_crtc *(*get_crtc)(struct drm_encoder *encoder);
f453ba04
DA
136 /* detect for DAC style encoders */
137 enum drm_connector_status (*detect)(struct drm_encoder *encoder,
138 struct drm_connector *connector);
a3a0544b
DA
139 /* disable encoder when not in use - more explicit than dpms off */
140 void (*disable)(struct drm_encoder *encoder);
4cd4df80
TR
141
142 /* atomic helpers */
143 int (*atomic_check)(struct drm_encoder *encoder,
144 struct drm_crtc_state *crtc_state,
145 struct drm_connector_state *conn_state);
f453ba04
DA
146};
147
3b02ab88 148/**
7552e7dd 149 * struct drm_connector_helper_funcs - helper operations for connectors
3b02ab88 150 * @get_modes: get mode list for this connector
7552e7dd
TR
151 * @mode_valid: is this mode valid on the given connector? (optional)
152 * @best_encoder: return the preferred encoder for this connector
3b02ab88
LP
153 *
154 * The helper operations are called by the mid-layer CRTC helper.
155 */
f453ba04
DA
156struct drm_connector_helper_funcs {
157 int (*get_modes)(struct drm_connector *connector);
0993f1d0
DL
158 enum drm_mode_status (*mode_valid)(struct drm_connector *connector,
159 struct drm_display_mode *mode);
f453ba04
DA
160 struct drm_encoder *(*best_encoder)(struct drm_connector *connector);
161};
162
f453ba04 163extern void drm_helper_disable_unused_functions(struct drm_device *dev);
f453ba04
DA
164extern int drm_crtc_helper_set_config(struct drm_mode_set *set);
165extern bool drm_crtc_helper_set_mode(struct drm_crtc *crtc,
166 struct drm_display_mode *mode,
3c4fdcfb
KH
167 int x, int y,
168 struct drm_framebuffer *old_fb);
f453ba04 169extern bool drm_helper_crtc_in_use(struct drm_crtc *crtc);
f380ef86 170extern bool drm_helper_encoder_in_use(struct drm_encoder *encoder);
f453ba04 171
c9fb15f6
KP
172extern void drm_helper_connector_dpms(struct drm_connector *connector, int mode);
173
cfc1a062
DV
174extern void drm_helper_move_panel_connectors_to_head(struct drm_device *);
175
9fd93784
DV
176extern void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
177 struct drm_mode_fb_cmd2 *mode_cmd);
f453ba04
DA
178
179static inline void drm_crtc_helper_add(struct drm_crtc *crtc,
180 const struct drm_crtc_helper_funcs *funcs)
181{
182 crtc->helper_private = (void *)funcs;
183}
184
185static inline void drm_encoder_helper_add(struct drm_encoder *encoder,
186 const struct drm_encoder_helper_funcs *funcs)
187{
188 encoder->helper_private = (void *)funcs;
189}
190
0b4c0f3f 191static inline void drm_connector_helper_add(struct drm_connector *connector,
f453ba04
DA
192 const struct drm_connector_helper_funcs *funcs)
193{
194 connector->helper_private = (void *)funcs;
195}
196
00d762cb 197extern void drm_helper_resume_force_mode(struct drm_device *dev);
8d754544 198
2f324b42
DV
199int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
200 struct drm_display_mode *adjusted_mode, int x, int y,
201 struct drm_framebuffer *old_fb);
202int drm_helper_crtc_mode_set_base(struct drm_crtc *crtc, int x, int y,
203 struct drm_framebuffer *old_fb);
204
8d754544
DV
205/* drm_probe_helper.c */
206extern int drm_helper_probe_single_connector_modes(struct drm_connector
207 *connector, uint32_t maxX,
208 uint32_t maxY);
b87577b7
DA
209extern int drm_helper_probe_single_connector_modes_nomerge(struct drm_connector
210 *connector,
211 uint32_t maxX,
212 uint32_t maxY);
eb1f8e4f
DA
213extern void drm_kms_helper_poll_init(struct drm_device *dev);
214extern void drm_kms_helper_poll_fini(struct drm_device *dev);
b8206d39 215extern bool drm_helper_hpd_irq_event(struct drm_device *dev);
3d3683f0 216extern void drm_kms_helper_hotplug_event(struct drm_device *dev);
fbf81762
DA
217
218extern void drm_kms_helper_poll_disable(struct drm_device *dev);
219extern void drm_kms_helper_poll_enable(struct drm_device *dev);
d0d110e0 220
f453ba04 221#endif
This page took 0.267838 seconds and 5 git commands to generate.