aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2015-12-04 03:45:44 -0500
committerDaniel Vetter <daniel.vetter@ffwll.ch>2015-12-08 10:07:52 -0500
commit092d01dae09aa6779ed41c3ac637e1e3c835424b (patch)
treeeb5803bb83f5a6327595f17585f2c5802bcf444a
parentb516a9efb7af38733ba2308fc7c0f49f034f53bd (diff)
drm: Reorganize helper vtables and their docs
Currently we have 4 helper libraries (probe, crtc, plane & atomic) that all use the same helper vtables. And that's by necessity since we don't want to litter the core structs with one ops pointer per helper library. Also often the reuse the same hooks (like atomic does, to facilite conversion from existing drivers using crtc and plane helpers). Given all that it doesn't make sense to put the docs for these next to specific helpers. Instead extract them into a new header file and section in the docbook, and add references to them everywhere. Unfortunately kernel-doc complains when an include directive doesn't find anything (and it does by dumping crap into the output file). We have to remove the now empty includes to avoid that, instead of leaving them in for future proofing. v2: More OCD in ordering functions. v3: Spelling plus collate copyright headers properly. Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1449218769-16577-4-git-send-email-daniel.vetter@ffwll.ch Reviewed-by: Thierry Reding <treding@nvidia.com>
-rw-r--r--Documentation/DocBook/gpu.tmpl6
-rw-r--r--drivers/gpu/drm/drm_atomic_helper.c6
-rw-r--r--drivers/gpu/drm/drm_crtc_helper.c5
-rw-r--r--drivers/gpu/drm/drm_plane_helper.c4
-rw-r--r--drivers/gpu/drm/drm_probe_helper.c3
-rw-r--r--include/drm/drm_crtc_helper.h158
-rw-r--r--include/drm/drm_modeset_helper_vtables.h257
-rw-r--r--include/drm/drm_plane_helper.h38
8 files changed, 282 insertions, 195 deletions
diff --git a/Documentation/DocBook/gpu.tmpl b/Documentation/DocBook/gpu.tmpl
index 03f01e76add7..bd608d0c5703 100644
--- a/Documentation/DocBook/gpu.tmpl
+++ b/Documentation/DocBook/gpu.tmpl
@@ -2303,8 +2303,12 @@ void intel_crt_init(struct drm_device *dev)
2303!Edrivers/gpu/drm/drm_atomic_helper.c 2303!Edrivers/gpu/drm/drm_atomic_helper.c
2304 </sect2> 2304 </sect2>
2305 <sect2> 2305 <sect2>
2306 <title>Modeset Helper Reference for Common Vtables</title>
2307!Iinclude/drm/drm_modeset_helper_vtables.h
2308!Pinclude/drm/drm_modeset_helper_vtables.h overview
2309 </sect2>
2310 <sect2>
2306 <title>Modeset Helper Functions Reference</title> 2311 <title>Modeset Helper Functions Reference</title>
2307!Iinclude/drm/drm_crtc_helper.h
2308!Edrivers/gpu/drm/drm_crtc_helper.c 2312!Edrivers/gpu/drm/drm_crtc_helper.c
2309!Pdrivers/gpu/drm/drm_crtc_helper.c overview 2313!Pdrivers/gpu/drm/drm_crtc_helper.c overview
2310 </sect2> 2314 </sect2>
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 74a5fc4deef6..ab275499d2a3 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -52,6 +52,12 @@
52 * drm_atomic_helper_disable_plane(), drm_atomic_helper_disable_plane() and the 52 * drm_atomic_helper_disable_plane(), drm_atomic_helper_disable_plane() and the
53 * various functions to implement set_property callbacks. New drivers must not 53 * various functions to implement set_property callbacks. New drivers must not
54 * implement these functions themselves but must use the provided helpers. 54 * implement these functions themselves but must use the provided helpers.
55 *
56 * The atomic helper uses the same function table structures as all other
57 * modesetting helpers. See the documentation for struct &drm_crtc_helper_funcs,
58 * struct &drm_encoder_helper_funcs and struct &drm_connector_helper_funcs. It
59 * also shares the struct &drm_plane_helper_funcs function table with the plane
60 * helpers.
55 */ 61 */
56static void 62static void
57drm_atomic_helper_plane_changed(struct drm_atomic_state *state, 63drm_atomic_helper_plane_changed(struct drm_atomic_state *state,
diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
index 10d0989db273..5dc92b66e07e 100644
--- a/drivers/gpu/drm/drm_crtc_helper.c
+++ b/drivers/gpu/drm/drm_crtc_helper.c
@@ -62,6 +62,11 @@
62 * converting to the plane helpers). New drivers must not use these functions 62 * converting to the plane helpers). New drivers must not use these functions
63 * but need to implement the atomic interface instead, potentially using the 63 * but need to implement the atomic interface instead, potentially using the
64 * atomic helpers for that. 64 * atomic helpers for that.
65 *
66 * These legacy modeset helpers use the same function table structures as
67 * all other modesetting helpers. See the documentation for struct
68 * &drm_crtc_helper_funcs, struct &drm_encoder_helper_funcs and struct
69 * &drm_connector_helper_funcs.
65 */ 70 */
66MODULE_AUTHOR("David Airlie, Jesse Barnes"); 71MODULE_AUTHOR("David Airlie, Jesse Barnes");
67MODULE_DESCRIPTION("DRM KMS helper"); 72MODULE_DESCRIPTION("DRM KMS helper");
diff --git a/drivers/gpu/drm/drm_plane_helper.c b/drivers/gpu/drm/drm_plane_helper.c
index a6983d41920d..8455e996dd9c 100644
--- a/drivers/gpu/drm/drm_plane_helper.c
+++ b/drivers/gpu/drm/drm_plane_helper.c
@@ -57,6 +57,10 @@
57 * by the atomic helpers. 57 * by the atomic helpers.
58 * 58 *
59 * Again drivers are strongly urged to switch to the new interfaces. 59 * Again drivers are strongly urged to switch to the new interfaces.
60 *
61 * The plane helpers share the function table structures with other helpers,
62 * specifically also the atomic helpers. See struct &drm_plane_helper_funcs for
63 * the details.
60 */ 64 */
61 65
62/* 66/*
diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c
index eee3b6f38cfb..b59acad83644 100644
--- a/drivers/gpu/drm/drm_probe_helper.c
+++ b/drivers/gpu/drm/drm_probe_helper.c
@@ -53,6 +53,9 @@
53 * This helper library can be used independently of the modeset helper library. 53 * This helper library can be used independently of the modeset helper library.
54 * Drivers can also overwrite different parts e.g. use their own hotplug 54 * Drivers can also overwrite different parts e.g. use their own hotplug
55 * handling code to avoid probing unrelated outputs. 55 * handling code to avoid probing unrelated outputs.
56 *
57 * The probe helpers share the function table structures with other display
58 * helper libraries. See struct &drm_connector_helper_funcs for the details.
56 */ 59 */
57 60
58static bool drm_kms_helper_poll = true; 61static bool drm_kms_helper_poll = true;
diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
index 26cc978f79e7..f94ff54ae25e 100644
--- a/include/drm/drm_crtc_helper.h
+++ b/include/drm/drm_crtc_helper.h
@@ -40,145 +40,7 @@
40#include <linux/fb.h> 40#include <linux/fb.h>
41 41
42#include <drm/drm_crtc.h> 42#include <drm/drm_crtc.h>
43 43#include <drm/drm_modeset_helper_vtables.h>
44enum mode_set_atomic;
45
46/**
47 * struct drm_crtc_helper_funcs - helper operations for CRTCs
48 * @dpms: set power state
49 * @prepare: prepare the CRTC, called before @mode_set
50 * @commit: commit changes to CRTC, called after @mode_set
51 * @mode_fixup: try to fixup proposed mode for this CRTC
52 * @mode_set: set this mode
53 * @mode_set_nofb: set mode only (no scanout buffer attached)
54 * @mode_set_base: update the scanout buffer
55 * @mode_set_base_atomic: non-blocking mode set (used for kgdb support)
56 * @load_lut: load color palette
57 * @disable: disable CRTC when no longer in use
58 * @enable: enable CRTC
59 * @atomic_check: check for validity of an atomic state
60 * @atomic_begin: begin atomic update
61 * @atomic_flush: flush atomic update
62 *
63 * The helper operations are called by the mid-layer CRTC helper.
64 *
65 * Note that with atomic helpers @dpms, @prepare and @commit hooks are
66 * deprecated. Used @enable and @disable instead exclusively.
67 *
68 * With legacy crtc helpers there's a big semantic difference between @disable
69 * and the other hooks: @disable also needs to release any resources acquired in
70 * @mode_set (like shared PLLs).
71 */
72struct drm_crtc_helper_funcs {
73 /*
74 * Control power levels on the CRTC. If the mode passed in is
75 * unsupported, the provider must use the next lowest power level.
76 */
77 void (*dpms)(struct drm_crtc *crtc, int mode);
78 void (*prepare)(struct drm_crtc *crtc);
79 void (*commit)(struct drm_crtc *crtc);
80
81 /* Provider can fixup or change mode timings before modeset occurs */
82 bool (*mode_fixup)(struct drm_crtc *crtc,
83 const struct drm_display_mode *mode,
84 struct drm_display_mode *adjusted_mode);
85 /* Actually set the mode */
86 int (*mode_set)(struct drm_crtc *crtc, struct drm_display_mode *mode,
87 struct drm_display_mode *adjusted_mode, int x, int y,
88 struct drm_framebuffer *old_fb);
89 /* Actually set the mode for atomic helpers, optional */
90 void (*mode_set_nofb)(struct drm_crtc *crtc);
91
92 /* Move the crtc on the current fb to the given position *optional* */
93 int (*mode_set_base)(struct drm_crtc *crtc, int x, int y,
94 struct drm_framebuffer *old_fb);
95 int (*mode_set_base_atomic)(struct drm_crtc *crtc,
96 struct drm_framebuffer *fb, int x, int y,
97 enum mode_set_atomic);
98
99 /* reload the current crtc LUT */
100 void (*load_lut)(struct drm_crtc *crtc);
101
102 void (*disable)(struct drm_crtc *crtc);
103 void (*enable)(struct drm_crtc *crtc);
104
105 /* atomic helpers */
106 int (*atomic_check)(struct drm_crtc *crtc,
107 struct drm_crtc_state *state);
108 void (*atomic_begin)(struct drm_crtc *crtc,
109 struct drm_crtc_state *old_crtc_state);
110 void (*atomic_flush)(struct drm_crtc *crtc,
111 struct drm_crtc_state *old_crtc_state);
112};
113
114/**
115 * struct drm_encoder_helper_funcs - helper operations for encoders
116 * @dpms: set power state
117 * @save: save connector state
118 * @restore: restore connector state
119 * @mode_fixup: try to fixup proposed mode for this connector
120 * @prepare: part of the disable sequence, called before the CRTC modeset
121 * @commit: called after the CRTC modeset
122 * @mode_set: set this mode, optional for atomic helpers
123 * @get_crtc: return CRTC that the encoder is currently attached to
124 * @detect: connection status detection
125 * @disable: disable encoder when not in use (overrides DPMS off)
126 * @enable: enable encoder
127 * @atomic_check: check for validity of an atomic update
128 *
129 * The helper operations are called by the mid-layer CRTC helper.
130 *
131 * Note that with atomic helpers @dpms, @prepare and @commit hooks are
132 * deprecated. Used @enable and @disable instead exclusively.
133 *
134 * With legacy crtc helpers there's a big semantic difference between @disable
135 * and the other hooks: @disable also needs to release any resources acquired in
136 * @mode_set (like shared PLLs).
137 */
138struct drm_encoder_helper_funcs {
139 void (*dpms)(struct drm_encoder *encoder, int mode);
140 void (*save)(struct drm_encoder *encoder);
141 void (*restore)(struct drm_encoder *encoder);
142
143 bool (*mode_fixup)(struct drm_encoder *encoder,
144 const struct drm_display_mode *mode,
145 struct drm_display_mode *adjusted_mode);
146 void (*prepare)(struct drm_encoder *encoder);
147 void (*commit)(struct drm_encoder *encoder);
148 void (*mode_set)(struct drm_encoder *encoder,
149 struct drm_display_mode *mode,
150 struct drm_display_mode *adjusted_mode);
151 struct drm_crtc *(*get_crtc)(struct drm_encoder *encoder);
152 /* detect for DAC style encoders */
153 enum drm_connector_status (*detect)(struct drm_encoder *encoder,
154 struct drm_connector *connector);
155 void (*disable)(struct drm_encoder *encoder);
156
157 void (*enable)(struct drm_encoder *encoder);
158
159 /* atomic helpers */
160 int (*atomic_check)(struct drm_encoder *encoder,
161 struct drm_crtc_state *crtc_state,
162 struct drm_connector_state *conn_state);
163};
164
165/**
166 * struct drm_connector_helper_funcs - helper operations for connectors
167 * @get_modes: get mode list for this connector
168 * @mode_valid: is this mode valid on the given connector? (optional)
169 * @best_encoder: return the preferred encoder for this connector
170 * @atomic_best_encoder: atomic version of @best_encoder
171 *
172 * The helper operations are called by the mid-layer CRTC helper.
173 */
174struct drm_connector_helper_funcs {
175 int (*get_modes)(struct drm_connector *connector);
176 enum drm_mode_status (*mode_valid)(struct drm_connector *connector,
177 struct drm_display_mode *mode);
178 struct drm_encoder *(*best_encoder)(struct drm_connector *connector);
179 struct drm_encoder *(*atomic_best_encoder)(struct drm_connector *connector,
180 struct drm_connector_state *connector_state);
181};
182 44
183extern void drm_helper_disable_unused_functions(struct drm_device *dev); 45extern void drm_helper_disable_unused_functions(struct drm_device *dev);
184extern int drm_crtc_helper_set_config(struct drm_mode_set *set); 46extern int drm_crtc_helper_set_config(struct drm_mode_set *set);
@@ -196,24 +58,6 @@ extern void drm_helper_move_panel_connectors_to_head(struct drm_device *);
196extern void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb, 58extern void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb,
197 const struct drm_mode_fb_cmd2 *mode_cmd); 59 const struct drm_mode_fb_cmd2 *mode_cmd);
198 60
199static inline void drm_crtc_helper_add(struct drm_crtc *crtc,
200 const struct drm_crtc_helper_funcs *funcs)
201{
202 crtc->helper_private = funcs;
203}
204
205static inline void drm_encoder_helper_add(struct drm_encoder *encoder,
206 const struct drm_encoder_helper_funcs *funcs)
207{
208 encoder->helper_private = funcs;
209}
210
211static inline void drm_connector_helper_add(struct drm_connector *connector,
212 const struct drm_connector_helper_funcs *funcs)
213{
214 connector->helper_private = funcs;
215}
216
217extern void drm_helper_resume_force_mode(struct drm_device *dev); 61extern void drm_helper_resume_force_mode(struct drm_device *dev);
218 62
219int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode, 63int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mode,
diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h
new file mode 100644
index 000000000000..875809158fc4
--- /dev/null
+++ b/include/drm/drm_modeset_helper_vtables.h
@@ -0,0 +1,257 @@
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 © 2011-2013 Intel Corporation
7 * Copyright © 2015 Intel Corporation
8 * Daniel Vetter <daniel.vetter@ffwll.ch>
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
24 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 * OTHER DEALINGS IN THE SOFTWARE.
27 */
28
29#ifndef __DRM_MODESET_HELPER_VTABLES_H__
30#define __DRM_MODESET_HELPER_VTABLES_H__
31
32#include <drm/drm_crtc.h>
33
34/**
35 * DOC: overview
36 *
37 * The DRM mode setting helper functions are common code for drivers to use if
38 * they wish. Drivers are not forced to use this code in their
39 * implementations but it would be useful if the code they do use at least
40 * provides a consistent interface and operation to userspace. Therefore it is
41 * highly recommended to use the provided helpers as much as possible.
42 *
43 * Because there is only one pointer per modeset object to hold a vfunc table
44 * for helper libraries they are by necessity shared among the different
45 * helpers.
46 *
47 * To make this clear all the helper vtables are pulled together in this location here.
48 */
49
50enum mode_set_atomic;
51
52/**
53 * struct drm_crtc_helper_funcs - helper operations for CRTCs
54 * @dpms: set power state
55 * @prepare: prepare the CRTC, called before @mode_set
56 * @commit: commit changes to CRTC, called after @mode_set
57 * @mode_fixup: try to fixup proposed mode for this CRTC
58 * @mode_set: set this mode
59 * @mode_set_nofb: set mode only (no scanout buffer attached)
60 * @mode_set_base: update the scanout buffer
61 * @mode_set_base_atomic: non-blocking mode set (used for kgdb support)
62 * @load_lut: load color palette
63 * @disable: disable CRTC when no longer in use
64 * @enable: enable CRTC
65 * @atomic_check: check for validity of an atomic state
66 * @atomic_begin: begin atomic update
67 * @atomic_flush: flush atomic update
68 *
69 * The helper operations are called by the mid-layer CRTC helper.
70 *
71 * Note that with atomic helpers @dpms, @prepare and @commit hooks are
72 * deprecated. Used @enable and @disable instead exclusively.
73 *
74 * With legacy crtc helpers there's a big semantic difference between @disable
75 * and the other hooks: @disable also needs to release any resources acquired in
76 * @mode_set (like shared PLLs).
77 */
78struct drm_crtc_helper_funcs {
79 /*
80 * Control power levels on the CRTC. If the mode passed in is
81 * unsupported, the provider must use the next lowest power level.
82 */
83 void (*dpms)(struct drm_crtc *crtc, int mode);
84 void (*prepare)(struct drm_crtc *crtc);
85 void (*commit)(struct drm_crtc *crtc);
86
87 /* Provider can fixup or change mode timings before modeset occurs */
88 bool (*mode_fixup)(struct drm_crtc *crtc,
89 const struct drm_display_mode *mode,
90 struct drm_display_mode *adjusted_mode);
91 /* Actually set the mode */
92 int (*mode_set)(struct drm_crtc *crtc, struct drm_display_mode *mode,
93 struct drm_display_mode *adjusted_mode, int x, int y,
94 struct drm_framebuffer *old_fb);
95 /* Actually set the mode for atomic helpers, optional */
96 void (*mode_set_nofb)(struct drm_crtc *crtc);
97
98 /* Move the crtc on the current fb to the given position *optional* */
99 int (*mode_set_base)(struct drm_crtc *crtc, int x, int y,
100 struct drm_framebuffer *old_fb);
101 int (*mode_set_base_atomic)(struct drm_crtc *crtc,
102 struct drm_framebuffer *fb, int x, int y,
103 enum mode_set_atomic);
104
105 /* reload the current crtc LUT */
106 void (*load_lut)(struct drm_crtc *crtc);
107
108 void (*disable)(struct drm_crtc *crtc);
109 void (*enable)(struct drm_crtc *crtc);
110
111 /* atomic helpers */
112 int (*atomic_check)(struct drm_crtc *crtc,
113 struct drm_crtc_state *state);
114 void (*atomic_begin)(struct drm_crtc *crtc,
115 struct drm_crtc_state *old_crtc_state);
116 void (*atomic_flush)(struct drm_crtc *crtc,
117 struct drm_crtc_state *old_crtc_state);
118};
119
120/**
121 * drm_crtc_helper_add - sets the helper vtable for a crtc
122 * @crtc: DRM CRTC
123 * @funcs: helper vtable to set for @crtc
124 */
125static inline void drm_crtc_helper_add(struct drm_crtc *crtc,
126 const struct drm_crtc_helper_funcs *funcs)
127{
128 crtc->helper_private = funcs;
129}
130
131/**
132 * struct drm_encoder_helper_funcs - helper operations for encoders
133 * @dpms: set power state
134 * @save: save connector state
135 * @restore: restore connector state
136 * @mode_fixup: try to fixup proposed mode for this connector
137 * @prepare: part of the disable sequence, called before the CRTC modeset
138 * @commit: called after the CRTC modeset
139 * @mode_set: set this mode, optional for atomic helpers
140 * @get_crtc: return CRTC that the encoder is currently attached to
141 * @detect: connection status detection
142 * @disable: disable encoder when not in use (overrides DPMS off)
143 * @enable: enable encoder
144 * @atomic_check: check for validity of an atomic update
145 *
146 * The helper operations are called by the mid-layer CRTC helper.
147 *
148 * Note that with atomic helpers @dpms, @prepare and @commit hooks are
149 * deprecated. Used @enable and @disable instead exclusively.
150 *
151 * With legacy crtc helpers there's a big semantic difference between @disable
152 * and the other hooks: @disable also needs to release any resources acquired in
153 * @mode_set (like shared PLLs).
154 */
155struct drm_encoder_helper_funcs {
156 void (*dpms)(struct drm_encoder *encoder, int mode);
157 void (*save)(struct drm_encoder *encoder);
158 void (*restore)(struct drm_encoder *encoder);
159
160 bool (*mode_fixup)(struct drm_encoder *encoder,
161 const struct drm_display_mode *mode,
162 struct drm_display_mode *adjusted_mode);
163 void (*prepare)(struct drm_encoder *encoder);
164 void (*commit)(struct drm_encoder *encoder);
165 void (*mode_set)(struct drm_encoder *encoder,
166 struct drm_display_mode *mode,
167 struct drm_display_mode *adjusted_mode);
168 struct drm_crtc *(*get_crtc)(struct drm_encoder *encoder);
169 /* detect for DAC style encoders */
170 enum drm_connector_status (*detect)(struct drm_encoder *encoder,
171 struct drm_connector *connector);
172 void (*disable)(struct drm_encoder *encoder);
173
174 void (*enable)(struct drm_encoder *encoder);
175
176 /* atomic helpers */
177 int (*atomic_check)(struct drm_encoder *encoder,
178 struct drm_crtc_state *crtc_state,
179 struct drm_connector_state *conn_state);
180};
181
182/**
183 * drm_encoder_helper_add - sets the helper vtable for a encoder
184 * @encoder: DRM encoder
185 * @funcs: helper vtable to set for @encoder
186 */
187static inline void drm_encoder_helper_add(struct drm_encoder *encoder,
188 const struct drm_encoder_helper_funcs *funcs)
189{
190 encoder->helper_private = funcs;
191}
192
193/**
194 * struct drm_connector_helper_funcs - helper operations for connectors
195 * @get_modes: get mode list for this connector
196 * @mode_valid: is this mode valid on the given connector? (optional)
197 * @best_encoder: return the preferred encoder for this connector
198 * @atomic_best_encoder: atomic version of @best_encoder
199 *
200 * The helper operations are called by the mid-layer CRTC helper.
201 */
202struct drm_connector_helper_funcs {
203 int (*get_modes)(struct drm_connector *connector);
204 enum drm_mode_status (*mode_valid)(struct drm_connector *connector,
205 struct drm_display_mode *mode);
206 struct drm_encoder *(*best_encoder)(struct drm_connector *connector);
207 struct drm_encoder *(*atomic_best_encoder)(struct drm_connector *connector,
208 struct drm_connector_state *connector_state);
209};
210
211/**
212 * drm_connector_helper_add - sets the helper vtable for a connector
213 * @connector: DRM connector
214 * @funcs: helper vtable to set for @connector
215 */
216static inline void drm_connector_helper_add(struct drm_connector *connector,
217 const struct drm_connector_helper_funcs *funcs)
218{
219 connector->helper_private = funcs;
220}
221
222/**
223 * struct drm_plane_helper_funcs - helper operations for CRTCs
224 * @prepare_fb: prepare a framebuffer for use by the plane
225 * @cleanup_fb: cleanup a framebuffer when it's no longer used by the plane
226 * @atomic_check: check that a given atomic state is valid and can be applied
227 * @atomic_update: apply an atomic state to the plane (mandatory)
228 * @atomic_disable: disable the plane
229 *
230 * The helper operations are called by the mid-layer CRTC helper.
231 */
232struct drm_plane_helper_funcs {
233 int (*prepare_fb)(struct drm_plane *plane,
234 const struct drm_plane_state *new_state);
235 void (*cleanup_fb)(struct drm_plane *plane,
236 const struct drm_plane_state *old_state);
237
238 int (*atomic_check)(struct drm_plane *plane,
239 struct drm_plane_state *state);
240 void (*atomic_update)(struct drm_plane *plane,
241 struct drm_plane_state *old_state);
242 void (*atomic_disable)(struct drm_plane *plane,
243 struct drm_plane_state *old_state);
244};
245
246/**
247 * drm_plane_helper_add - sets the helper vtable for a plane
248 * @plane: DRM plane
249 * @funcs: helper vtable to set for @plane
250 */
251static inline void drm_plane_helper_add(struct drm_plane *plane,
252 const struct drm_plane_helper_funcs *funcs)
253{
254 plane->helper_private = funcs;
255}
256
257#endif
diff --git a/include/drm/drm_plane_helper.h b/include/drm/drm_plane_helper.h
index 5a7f9d4efb1d..4421f3f4ca8d 100644
--- a/include/drm/drm_plane_helper.h
+++ b/include/drm/drm_plane_helper.h
@@ -26,6 +26,7 @@
26 26
27#include <drm/drm_rect.h> 27#include <drm/drm_rect.h>
28#include <drm/drm_crtc.h> 28#include <drm/drm_crtc.h>
29#include <drm/drm_modeset_helper_vtables.h>
29 30
30/* 31/*
31 * Drivers that don't allow primary plane scaling may pass this macro in place 32 * Drivers that don't allow primary plane scaling may pass this macro in place
@@ -36,46 +37,9 @@
36 */ 37 */
37#define DRM_PLANE_HELPER_NO_SCALING (1<<16) 38#define DRM_PLANE_HELPER_NO_SCALING (1<<16)
38 39
39/**
40 * DOC: plane helpers
41 *
42 * Helper functions to assist with creation and handling of CRTC primary
43 * planes.
44 */
45
46int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc, 40int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
47 const struct drm_crtc_funcs *funcs); 41 const struct drm_crtc_funcs *funcs);
48 42
49/**
50 * drm_plane_helper_funcs - helper operations for CRTCs
51 * @prepare_fb: prepare a framebuffer for use by the plane
52 * @cleanup_fb: cleanup a framebuffer when it's no longer used by the plane
53 * @atomic_check: check that a given atomic state is valid and can be applied
54 * @atomic_update: apply an atomic state to the plane (mandatory)
55 * @atomic_disable: disable the plane
56 *
57 * The helper operations are called by the mid-layer CRTC helper.
58 */
59struct drm_plane_helper_funcs {
60 int (*prepare_fb)(struct drm_plane *plane,
61 const struct drm_plane_state *new_state);
62 void (*cleanup_fb)(struct drm_plane *plane,
63 const struct drm_plane_state *old_state);
64
65 int (*atomic_check)(struct drm_plane *plane,
66 struct drm_plane_state *state);
67 void (*atomic_update)(struct drm_plane *plane,
68 struct drm_plane_state *old_state);
69 void (*atomic_disable)(struct drm_plane *plane,
70 struct drm_plane_state *old_state);
71};
72
73static inline void drm_plane_helper_add(struct drm_plane *plane,
74 const struct drm_plane_helper_funcs *funcs)
75{
76 plane->helper_private = funcs;
77}
78
79int drm_plane_helper_check_update(struct drm_plane *plane, 43int drm_plane_helper_check_update(struct drm_plane *plane,
80 struct drm_crtc *crtc, 44 struct drm_crtc *crtc,
81 struct drm_framebuffer *fb, 45 struct drm_framebuffer *fb,