]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blame - include/drm/drm_simple_kms_helper.h
drm/udl: Get rid of dev->struct_mutex usage
[mirror_ubuntu-eoan-kernel.git] / include / drm / drm_simple_kms_helper.h
CommitLineData
5b809074
NT
1/*
2 * Copyright (C) 2016 Noralf Trønnes
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 */
9
10#ifndef __LINUX_DRM_SIMPLE_KMS_HELPER_H
11#define __LINUX_DRM_SIMPLE_KMS_HELPER_H
12
a6a9534c
NT
13#include <drm/drm_crtc.h>
14#include <drm/drm_encoder.h>
15#include <drm/drm_plane.h>
16
5b809074
NT
17struct drm_simple_display_pipe;
18
19/**
20 * struct drm_simple_display_pipe_funcs - helper operations for a simple
21 * display pipeline
22 */
23struct drm_simple_display_pipe_funcs {
40275dc4
LW
24 /**
25 * @mode_valid:
26 *
afe09e43
LW
27 * This callback is used to check if a specific mode is valid in the
28 * crtc used in this simple display pipe. This should be implemented
29 * if the display pipe has some sort of restriction in the modes
30 * it can display. For example, a given display pipe may be responsible
31 * to set a clock value. If the clock can not produce all the values
32 * for the available modes then this callback can be used to restrict
33 * the number of modes to only the ones that can be displayed. Another
34 * reason can be bandwidth mitigation: the memory port on the display
35 * controller can have bandwidth limitations not allowing pixel data
36 * to be fetched at any rate.
37 *
38 * This hook is used by the probe helpers to filter the mode list in
39 * drm_helper_probe_single_connector_modes(), and it is used by the
40 * atomic helpers to validate modes supplied by userspace in
41 * drm_atomic_helper_check_modeset().
42 *
43 * This function is optional.
44 *
45 * NOTE:
46 *
47 * Since this function is both called from the check phase of an atomic
48 * commit, and the mode validation in the probe paths it is not allowed
49 * to look at anything else but the passed-in mode, and validate it
50 * against configuration-invariant hardware constraints.
40275dc4
LW
51 *
52 * RETURNS:
53 *
54 * drm_mode_status Enum
55 */
56 enum drm_mode_status (*mode_valid)(struct drm_crtc *crtc,
57 const struct drm_display_mode *mode);
58
5b809074
NT
59 /**
60 * @enable:
61 *
62 * This function should be used to enable the pipeline.
63 * It is called when the underlying crtc is enabled.
64 * This hook is optional.
65 */
66 void (*enable)(struct drm_simple_display_pipe *pipe,
67 struct drm_crtc_state *crtc_state);
68 /**
69 * @disable:
70 *
71 * This function should be used to disable the pipeline.
72 * It is called when the underlying crtc is disabled.
73 * This hook is optional.
74 */
75 void (*disable)(struct drm_simple_display_pipe *pipe);
76
77 /**
78 * @check:
79 *
80 * This function is called in the check phase of an atomic update,
81 * specifically when the underlying plane is checked.
82 * The simple display pipeline helpers already check that the plane is
83 * not scaled, fills the entire visible area and is always enabled
84 * when the crtc is also enabled.
85 * This hook is optional.
86 *
87 * RETURNS:
88 *
89 * 0 on success, -EINVAL if the state or the transition can't be
90 * supported, -ENOMEM on memory allocation failure and -EDEADLK if an
91 * attempt to obtain another state object ran into a &drm_modeset_lock
92 * deadlock.
93 */
94 int (*check)(struct drm_simple_display_pipe *pipe,
95 struct drm_plane_state *plane_state,
96 struct drm_crtc_state *crtc_state);
97 /**
98 * @update:
99 *
100 * This function is called when the underlying plane state is updated.
101 * This hook is optional.
6dcf0de7
DV
102 *
103 * This is the function drivers should submit the
104 * &drm_pending_vblank_event from. Using either
105 * drm_crtc_arm_vblank_event(), when the driver supports vblank
106 * interrupt handling, or drm_crtc_send_vblank_event() directly in case
107 * the hardware lacks vblank support entirely.
5b809074
NT
108 */
109 void (*update)(struct drm_simple_display_pipe *pipe,
bcd2ba02 110 struct drm_plane_state *old_plane_state);
7d83a155
MV
111
112 /**
113 * @prepare_fb:
114 *
6806cdf9
DV
115 * Optional, called by &drm_plane_helper_funcs.prepare_fb. Please read
116 * the documentation for the &drm_plane_helper_funcs.prepare_fb hook for
117 * more details.
7d83a155
MV
118 */
119 int (*prepare_fb)(struct drm_simple_display_pipe *pipe,
120 struct drm_plane_state *plane_state);
121
122 /**
123 * @cleanup_fb:
124 *
6806cdf9
DV
125 * Optional, called by &drm_plane_helper_funcs.cleanup_fb. Please read
126 * the documentation for the &drm_plane_helper_funcs.cleanup_fb hook for
127 * more details.
7d83a155
MV
128 */
129 void (*cleanup_fb)(struct drm_simple_display_pipe *pipe,
130 struct drm_plane_state *plane_state);
ac86cba9
OA
131
132 /**
133 * @enable_vblank:
134 *
135 * Optional, called by &drm_crtc_funcs.enable_vblank. Please read
136 * the documentation for the &drm_crtc_funcs.enable_vblank hook for
137 * more details.
138 */
139 int (*enable_vblank)(struct drm_simple_display_pipe *pipe);
140
141 /**
142 * @disable_vblank:
143 *
144 * Optional, called by &drm_crtc_funcs.disable_vblank. Please read
145 * the documentation for the &drm_crtc_funcs.disable_vblank hook for
146 * more details.
147 */
148 void (*disable_vblank)(struct drm_simple_display_pipe *pipe);
5b809074
NT
149};
150
151/**
152 * struct drm_simple_display_pipe - simple display pipeline
153 * @crtc: CRTC control structure
154 * @plane: Plane control structure
155 * @encoder: Encoder control structure
156 * @connector: Connector control structure
157 * @funcs: Pipeline control functions (optional)
158 *
159 * Simple display pipeline with plane, crtc and encoder collapsed into one
160 * entity. It should be initialized by calling drm_simple_display_pipe_init().
161 */
162struct drm_simple_display_pipe {
163 struct drm_crtc crtc;
164 struct drm_plane plane;
165 struct drm_encoder encoder;
166 struct drm_connector *connector;
167
168 const struct drm_simple_display_pipe_funcs *funcs;
169};
170
315486c6
AM
171int drm_simple_display_pipe_attach_bridge(struct drm_simple_display_pipe *pipe,
172 struct drm_bridge *bridge);
173
5b809074
NT
174int drm_simple_display_pipe_init(struct drm_device *dev,
175 struct drm_simple_display_pipe *pipe,
176 const struct drm_simple_display_pipe_funcs *funcs,
177 const uint32_t *formats, unsigned int format_count,
e6fc3b68 178 const uint64_t *format_modifiers,
5b809074
NT
179 struct drm_connector *connector);
180
181#endif /* __LINUX_DRM_SIMPLE_KMS_HELPER_H */