Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 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 | #ifndef __DRM_CRTC_H__ |
| 26 | #define __DRM_CRTC_H__ |
| 27 | |
| 28 | #include <linux/i2c.h> |
| 29 | #include <linux/spinlock.h> |
| 30 | #include <linux/types.h> |
| 31 | #include <linux/idr.h> |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 32 | #include <linux/fb.h> |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 33 | #include <linux/hdmi.h> |
Boris Brezillon | b5571e9 | 2014-07-22 12:09:10 +0200 | [diff] [blame] | 34 | #include <linux/media-bus-format.h> |
David Herrmann | d7d2c48 | 2014-08-29 12:12:40 +0200 | [diff] [blame] | 35 | #include <uapi/drm/drm_mode.h> |
| 36 | #include <uapi/drm/drm_fourcc.h> |
Rob Clark | 51fd371 | 2013-11-19 12:10:12 -0500 | [diff] [blame] | 37 | #include <drm/drm_modeset_lock.h> |
Ville Syrjälä | d7da824 | 2016-07-26 19:06:57 +0300 | [diff] [blame] | 38 | #include <drm/drm_rect.h> |
Daniel Vetter | 949619f | 2016-08-29 10:27:51 +0200 | [diff] [blame] | 39 | #include <drm/drm_mode_object.h> |
Daniel Vetter | 7520a27 | 2016-08-15 16:07:02 +0200 | [diff] [blame] | 40 | #include <drm/drm_framebuffer.h> |
| 41 | #include <drm/drm_modes.h> |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 42 | #include <drm/drm_connector.h> |
Daniel Vetter | 321a95a | 2016-08-29 10:27:49 +0200 | [diff] [blame] | 43 | #include <drm/drm_encoder.h> |
Daniel Vetter | 59e71ee | 2016-08-29 10:27:55 +0200 | [diff] [blame] | 44 | #include <drm/drm_property.h> |
Daniel Vetter | 199e4e9 | 2016-08-31 18:09:05 +0200 | [diff] [blame] | 45 | #include <drm/drm_bridge.h> |
Daniel Vetter | cdc3d09 | 2016-08-31 18:09:06 +0200 | [diff] [blame] | 46 | #include <drm/drm_edid.h> |
Daniel Vetter | 43968d7 | 2016-09-21 10:59:24 +0200 | [diff] [blame] | 47 | #include <drm/drm_plane.h> |
Daniel Vetter | 1873380 | 2016-09-21 10:59:26 +0200 | [diff] [blame] | 48 | #include <drm/drm_blend.h> |
Daniel Vetter | f1e2f66 | 2016-09-21 10:59:28 +0200 | [diff] [blame] | 49 | #include <drm/drm_color_mgmt.h> |
Jesse Barnes | 308e5bc | 2011-11-14 14:51:28 -0800 | [diff] [blame] | 50 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 51 | struct drm_device; |
| 52 | struct drm_mode_set; |
Thierry Reding | 595887e | 2012-11-21 15:00:47 +0100 | [diff] [blame] | 53 | struct drm_file; |
| 54 | struct drm_clip_rect; |
Russell King | 7e435aa | 2014-06-15 11:07:12 +0100 | [diff] [blame] | 55 | struct device_node; |
Daniel Vetter | e2330f0 | 2014-10-29 11:34:56 +0100 | [diff] [blame] | 56 | struct fence; |
Daniel Vetter | 8106554 | 2016-06-21 10:54:13 +0200 | [diff] [blame] | 57 | struct edid; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 58 | |
Rob Clark | ebc44cf | 2012-09-12 22:22:31 -0500 | [diff] [blame] | 59 | static inline int64_t U642I64(uint64_t val) |
| 60 | { |
| 61 | return (int64_t)*((int64_t *)&val); |
| 62 | } |
| 63 | static inline uint64_t I642U64(int64_t val) |
| 64 | { |
| 65 | return (uint64_t)*((uint64_t *)&val); |
| 66 | } |
| 67 | |
Dave Airlie | 138f9eb | 2014-10-20 16:17:17 +1000 | [diff] [blame] | 68 | /* data corresponds to displayid vend/prod/serial */ |
| 69 | struct drm_tile_group { |
| 70 | struct kref refcount; |
| 71 | struct drm_device *dev; |
| 72 | int id; |
| 73 | u8 group_data[8]; |
| 74 | }; |
| 75 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 76 | struct drm_crtc; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 77 | struct drm_encoder; |
Kristian Høgsberg | d91d8a3 | 2009-11-17 12:43:55 -0500 | [diff] [blame] | 78 | struct drm_pending_vblank_event; |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 79 | struct drm_plane; |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 80 | struct drm_bridge; |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 81 | struct drm_atomic_state; |
| 82 | |
Daniel Vetter | 4490d4c | 2015-12-04 09:45:45 +0100 | [diff] [blame] | 83 | struct drm_crtc_helper_funcs; |
| 84 | struct drm_encoder_helper_funcs; |
Daniel Vetter | 4490d4c | 2015-12-04 09:45:45 +0100 | [diff] [blame] | 85 | struct drm_plane_helper_funcs; |
| 86 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 87 | /** |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 88 | * struct drm_crtc_state - mutable CRTC state |
Daniel Vetter | 07cc0ef | 2014-11-27 15:49:39 +0100 | [diff] [blame] | 89 | * @crtc: backpointer to the CRTC |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 90 | * @enable: whether the CRTC should be enabled, gates all other state |
Daniel Vetter | d9b1362 | 2014-11-26 16:57:41 +0100 | [diff] [blame] | 91 | * @active: whether the CRTC is actively displaying (used for DPMS) |
Maarten Lankhorst | fc59666 | 2015-07-21 13:28:57 +0200 | [diff] [blame] | 92 | * @planes_changed: planes on this crtc are updated |
| 93 | * @mode_changed: crtc_state->mode or crtc_state->enable has been changed |
| 94 | * @active_changed: crtc_state->active has been toggled. |
| 95 | * @connectors_changed: connectors to this crtc have been updated |
Marek Szyprowski | 44d1240d | 2016-06-13 11:11:26 +0200 | [diff] [blame] | 96 | * @zpos_changed: zpos values of planes on this crtc have been updated |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 97 | * @color_mgmt_changed: color management properties have changed (degamma or |
| 98 | * gamma LUT or CSC matrix) |
Rob Clark | 6ddd388 | 2014-11-21 15:28:31 -0500 | [diff] [blame] | 99 | * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes |
Maarten Lankhorst | 4cd9fa5 | 2016-01-04 12:53:18 +0100 | [diff] [blame] | 100 | * @connector_mask: bitmask of (1 << drm_connector_index(connector)) of attached connectors |
Maarten Lankhorst | e87a52b | 2016-01-28 15:04:58 +0100 | [diff] [blame] | 101 | * @encoder_mask: bitmask of (1 << drm_encoder_index(encoder)) of attached encoders |
Daniel Vetter | 623369e | 2014-09-16 17:50:47 +0200 | [diff] [blame] | 102 | * @last_vblank_count: for helpers and drivers to capture the vblank of the |
| 103 | * update to ensure framebuffer cleanup isn't done too early |
Daniel Vetter | 2f324b4 | 2014-10-29 11:13:47 +0100 | [diff] [blame] | 104 | * @adjusted_mode: for use by helpers and drivers to compute adjusted mode timings |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 105 | * @mode: current mode timings |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 106 | * @mode_blob: &drm_property_blob for @mode |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 107 | * @degamma_lut: Lookup table for converting framebuffer pixel data |
| 108 | * before apply the conversion matrix |
| 109 | * @ctm: Transformation matrix |
| 110 | * @gamma_lut: Lookup table for converting pixel data after the |
| 111 | * conversion matrix |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 112 | * @state: backpointer to global drm_atomic_state |
Daniel Vetter | d9b1362 | 2014-11-26 16:57:41 +0100 | [diff] [blame] | 113 | * |
| 114 | * Note that the distinction between @enable and @active is rather subtile: |
| 115 | * Flipping @active while @enable is set without changing anything else may |
| 116 | * never return in a failure from the ->atomic_check callback. Userspace assumes |
| 117 | * that a DPMS On will always succeed. In other words: @enable controls resource |
| 118 | * assignment, @active controls the actual hardware state. |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 119 | */ |
| 120 | struct drm_crtc_state { |
Daniel Vetter | 07cc0ef | 2014-11-27 15:49:39 +0100 | [diff] [blame] | 121 | struct drm_crtc *crtc; |
| 122 | |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 123 | bool enable; |
Daniel Vetter | d9b1362 | 2014-11-26 16:57:41 +0100 | [diff] [blame] | 124 | bool active; |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 125 | |
Daniel Vetter | c2fcd27 | 2014-11-05 00:14:14 +0100 | [diff] [blame] | 126 | /* computed state bits used by helpers and drivers */ |
| 127 | bool planes_changed : 1; |
Daniel Vetter | 623369e | 2014-09-16 17:50:47 +0200 | [diff] [blame] | 128 | bool mode_changed : 1; |
Daniel Vetter | eab3bbe | 2015-01-22 16:36:21 +0100 | [diff] [blame] | 129 | bool active_changed : 1; |
Maarten Lankhorst | fc59666 | 2015-07-21 13:28:57 +0200 | [diff] [blame] | 130 | bool connectors_changed : 1; |
Marek Szyprowski | 44d1240d | 2016-06-13 11:11:26 +0200 | [diff] [blame] | 131 | bool zpos_changed : 1; |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 132 | bool color_mgmt_changed : 1; |
Daniel Vetter | 623369e | 2014-09-16 17:50:47 +0200 | [diff] [blame] | 133 | |
Rob Clark | 6ddd388 | 2014-11-21 15:28:31 -0500 | [diff] [blame] | 134 | /* attached planes bitmask: |
| 135 | * WARNING: transitional helpers do not maintain plane_mask so |
| 136 | * drivers not converted over to atomic helpers should not rely |
| 137 | * on plane_mask being accurate! |
| 138 | */ |
| 139 | u32 plane_mask; |
| 140 | |
Maarten Lankhorst | 4cd9fa5 | 2016-01-04 12:53:18 +0100 | [diff] [blame] | 141 | u32 connector_mask; |
Maarten Lankhorst | e87a52b | 2016-01-28 15:04:58 +0100 | [diff] [blame] | 142 | u32 encoder_mask; |
Maarten Lankhorst | 4cd9fa5 | 2016-01-04 12:53:18 +0100 | [diff] [blame] | 143 | |
Daniel Vetter | 623369e | 2014-09-16 17:50:47 +0200 | [diff] [blame] | 144 | /* last_vblank_count: for vblank waits before cleanup */ |
| 145 | u32 last_vblank_count; |
Daniel Vetter | c2fcd27 | 2014-11-05 00:14:14 +0100 | [diff] [blame] | 146 | |
Daniel Vetter | 2f324b4 | 2014-10-29 11:13:47 +0100 | [diff] [blame] | 147 | /* adjusted_mode: for use by helpers and drivers */ |
| 148 | struct drm_display_mode adjusted_mode; |
| 149 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 150 | struct drm_display_mode mode; |
| 151 | |
Daniel Stone | 99cf4a2 | 2015-05-25 19:11:51 +0100 | [diff] [blame] | 152 | /* blob property to expose current mode to atomic userspace */ |
| 153 | struct drm_property_blob *mode_blob; |
| 154 | |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 155 | /* blob property to expose color management to userspace */ |
| 156 | struct drm_property_blob *degamma_lut; |
| 157 | struct drm_property_blob *ctm; |
| 158 | struct drm_property_blob *gamma_lut; |
| 159 | |
Daniel Vetter | 6180213 | 2016-09-30 12:04:56 +0200 | [diff] [blame] | 160 | /** |
| 161 | * @event: |
| 162 | * |
| 163 | * Optional pointer to a DRM event to signal upon completion of the |
| 164 | * state update. The driver must send out the event when the atomic |
| 165 | * commit operation completes. There are two cases: |
| 166 | * |
| 167 | * - The event is for a CRTC which is being disabled through this |
| 168 | * atomic commit. In that case the event can be send out any time |
| 169 | * after the hardware has stopped scanning out the current |
| 170 | * framebuffers. It should contain the timestamp and counter for the |
| 171 | * last vblank before the display pipeline was shut off. |
| 172 | * |
| 173 | * - For a CRTC which is enabled at the end of the commit (even when it |
| 174 | * undergoes an full modeset) the vblank timestamp and counter must |
| 175 | * be for the vblank right before the first frame that scans out the |
| 176 | * new set of buffers. Again the event can only be sent out after the |
| 177 | * hardware has stopped scanning out the old buffers. |
| 178 | * |
| 179 | * - Events for disabled CRTCs are not allowed, and drivers can ignore |
| 180 | * that case. |
| 181 | * |
| 182 | * This can be handled by the drm_crtc_send_vblank_event() function, |
| 183 | * which the driver should call on the provided event upon completion of |
| 184 | * the atomic commit. Note that if the driver supports vblank signalling |
| 185 | * and timestamping the vblank counters and timestamps must agree with |
| 186 | * the ones returned from page flip events. With the current vblank |
| 187 | * helper infrastructure this can be achieved by holding a vblank |
| 188 | * reference while the page flip is pending, acquired through |
| 189 | * drm_crtc_vblank_get() and released with drm_crtc_vblank_put(). |
| 190 | * Drivers are free to implement their own vblank counter and timestamp |
| 191 | * tracking though, e.g. if they have accurate timestamp registers in |
| 192 | * hardware. |
| 193 | * |
| 194 | * For hardware which supports some means to synchronize vblank |
| 195 | * interrupt delivery with committing display state there's also |
| 196 | * drm_crtc_arm_vblank_event(). See the documentation of that function |
| 197 | * for a detailed discussion of the constraints it needs to be used |
| 198 | * safely. |
| 199 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 200 | struct drm_pending_vblank_event *event; |
| 201 | |
| 202 | struct drm_atomic_state *state; |
| 203 | }; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 204 | |
| 205 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 206 | * struct drm_crtc_funcs - control CRTCs for a given device |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 207 | * |
| 208 | * The drm_crtc_funcs structure is the central CRTC management structure |
| 209 | * in the DRM. Each CRTC controls one or more connectors (note that the name |
| 210 | * CRTC is simply historical, a CRTC may control LVDS, VGA, DVI, TV out, etc. |
| 211 | * connectors, not just CRTs). |
| 212 | * |
| 213 | * Each driver is responsible for filling out this structure at startup time, |
| 214 | * in addition to providing other modesetting features, like i2c and DDC |
| 215 | * bus accessors. |
| 216 | */ |
| 217 | struct drm_crtc_funcs { |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 218 | /** |
| 219 | * @reset: |
| 220 | * |
| 221 | * Reset CRTC hardware and software state to off. This function isn't |
| 222 | * called by the core directly, only through drm_mode_config_reset(). |
| 223 | * It's not a helper hook only for historical reasons. |
| 224 | * |
| 225 | * Atomic drivers can use drm_atomic_helper_crtc_reset() to reset |
| 226 | * atomic state using this hook. |
| 227 | */ |
Chris Wilson | eb03355 | 2011-01-24 15:11:08 +0000 | [diff] [blame] | 228 | void (*reset)(struct drm_crtc *crtc); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 229 | |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 230 | /** |
| 231 | * @cursor_set: |
| 232 | * |
| 233 | * Update the cursor image. The cursor position is relative to the CRTC |
| 234 | * and can be partially or fully outside of the visible area. |
| 235 | * |
| 236 | * Note that contrary to all other KMS functions the legacy cursor entry |
| 237 | * points don't take a framebuffer object, but instead take directly a |
| 238 | * raw buffer object id from the driver's buffer manager (which is |
| 239 | * either GEM or TTM for current drivers). |
| 240 | * |
| 241 | * This entry point is deprecated, drivers should instead implement |
| 242 | * universal plane support and register a proper cursor plane using |
| 243 | * drm_crtc_init_with_planes(). |
| 244 | * |
| 245 | * This callback is optional |
| 246 | * |
| 247 | * RETURNS: |
| 248 | * |
| 249 | * 0 on success or a negative error code on failure. |
| 250 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 251 | int (*cursor_set)(struct drm_crtc *crtc, struct drm_file *file_priv, |
| 252 | uint32_t handle, uint32_t width, uint32_t height); |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 253 | |
| 254 | /** |
| 255 | * @cursor_set2: |
| 256 | * |
| 257 | * Update the cursor image, including hotspot information. The hotspot |
| 258 | * must not affect the cursor position in CRTC coordinates, but is only |
| 259 | * meant as a hint for virtualized display hardware to coordinate the |
| 260 | * guests and hosts cursor position. The cursor hotspot is relative to |
| 261 | * the cursor image. Otherwise this works exactly like @cursor_set. |
| 262 | * |
| 263 | * This entry point is deprecated, drivers should instead implement |
| 264 | * universal plane support and register a proper cursor plane using |
| 265 | * drm_crtc_init_with_planes(). |
| 266 | * |
| 267 | * This callback is optional. |
| 268 | * |
| 269 | * RETURNS: |
| 270 | * |
| 271 | * 0 on success or a negative error code on failure. |
| 272 | */ |
Dave Airlie | 4c813d4 | 2013-06-20 11:48:52 +1000 | [diff] [blame] | 273 | int (*cursor_set2)(struct drm_crtc *crtc, struct drm_file *file_priv, |
| 274 | uint32_t handle, uint32_t width, uint32_t height, |
| 275 | int32_t hot_x, int32_t hot_y); |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 276 | |
| 277 | /** |
| 278 | * @cursor_move: |
| 279 | * |
| 280 | * Update the cursor position. The cursor does not need to be visible |
| 281 | * when this hook is called. |
| 282 | * |
| 283 | * This entry point is deprecated, drivers should instead implement |
| 284 | * universal plane support and register a proper cursor plane using |
| 285 | * drm_crtc_init_with_planes(). |
| 286 | * |
| 287 | * This callback is optional. |
| 288 | * |
| 289 | * RETURNS: |
| 290 | * |
| 291 | * 0 on success or a negative error code on failure. |
| 292 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 293 | int (*cursor_move)(struct drm_crtc *crtc, int x, int y); |
| 294 | |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 295 | /** |
| 296 | * @gamma_set: |
| 297 | * |
| 298 | * Set gamma on the CRTC. |
| 299 | * |
| 300 | * This callback is optional. |
| 301 | * |
| 302 | * NOTE: |
| 303 | * |
| 304 | * Drivers that support gamma tables and also fbdev emulation through |
| 305 | * the provided helper library need to take care to fill out the gamma |
| 306 | * hooks for both. Currently there's a bit an unfortunate duplication |
| 307 | * going on, which should eventually be unified to just one set of |
| 308 | * hooks. |
| 309 | */ |
Maarten Lankhorst | 7ea7728 | 2016-06-07 12:49:30 +0200 | [diff] [blame] | 310 | int (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, |
| 311 | uint32_t size); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 312 | |
| 313 | /** |
| 314 | * @destroy: |
| 315 | * |
| 316 | * Clean up plane resources. This is only called at driver unload time |
| 317 | * through drm_mode_config_cleanup() since a CRTC cannot be hotplugged |
| 318 | * in DRM. |
| 319 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 320 | void (*destroy)(struct drm_crtc *crtc); |
| 321 | |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 322 | /** |
| 323 | * @set_config: |
| 324 | * |
| 325 | * This is the main legacy entry point to change the modeset state on a |
| 326 | * CRTC. All the details of the desired configuration are passed in a |
| 327 | * struct &drm_mode_set - see there for details. |
| 328 | * |
| 329 | * Drivers implementing atomic modeset should use |
| 330 | * drm_atomic_helper_set_config() to implement this hook. |
| 331 | * |
| 332 | * RETURNS: |
| 333 | * |
| 334 | * 0 on success or a negative error code on failure. |
| 335 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 336 | int (*set_config)(struct drm_mode_set *set); |
Kristian Høgsberg | d91d8a3 | 2009-11-17 12:43:55 -0500 | [diff] [blame] | 337 | |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 338 | /** |
| 339 | * @page_flip: |
| 340 | * |
| 341 | * Legacy entry point to schedule a flip to the given framebuffer. |
| 342 | * |
| 343 | * Page flipping is a synchronization mechanism that replaces the frame |
| 344 | * buffer being scanned out by the CRTC with a new frame buffer during |
| 345 | * vertical blanking, avoiding tearing (except when requested otherwise |
| 346 | * through the DRM_MODE_PAGE_FLIP_ASYNC flag). When an application |
| 347 | * requests a page flip the DRM core verifies that the new frame buffer |
| 348 | * is large enough to be scanned out by the CRTC in the currently |
| 349 | * configured mode and then calls the CRTC ->page_flip() operation with a |
| 350 | * pointer to the new frame buffer. |
| 351 | * |
| 352 | * The driver must wait for any pending rendering to the new framebuffer |
| 353 | * to complete before executing the flip. It should also wait for any |
| 354 | * pending rendering from other drivers if the underlying buffer is a |
| 355 | * shared dma-buf. |
| 356 | * |
| 357 | * An application can request to be notified when the page flip has |
| 358 | * completed. The drm core will supply a struct &drm_event in the event |
| 359 | * parameter in this case. This can be handled by the |
| 360 | * drm_crtc_send_vblank_event() function, which the driver should call on |
| 361 | * the provided event upon completion of the flip. Note that if |
| 362 | * the driver supports vblank signalling and timestamping the vblank |
| 363 | * counters and timestamps must agree with the ones returned from page |
| 364 | * flip events. With the current vblank helper infrastructure this can |
| 365 | * be achieved by holding a vblank reference while the page flip is |
| 366 | * pending, acquired through drm_crtc_vblank_get() and released with |
| 367 | * drm_crtc_vblank_put(). Drivers are free to implement their own vblank |
| 368 | * counter and timestamp tracking though, e.g. if they have accurate |
| 369 | * timestamp registers in hardware. |
| 370 | * |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 371 | * This callback is optional. |
| 372 | * |
| 373 | * NOTE: |
| 374 | * |
| 375 | * Very early versions of the KMS ABI mandated that the driver must |
| 376 | * block (but not reject) any rendering to the old framebuffer until the |
| 377 | * flip operation has completed and the old framebuffer is no longer |
| 378 | * visible. This requirement has been lifted, and userspace is instead |
| 379 | * expected to request delivery of an event and wait with recycling old |
| 380 | * buffers until such has been received. |
| 381 | * |
| 382 | * RETURNS: |
| 383 | * |
| 384 | * 0 on success or a negative error code on failure. Note that if a |
| 385 | * ->page_flip() operation is already pending the callback should return |
| 386 | * -EBUSY. Pageflips on a disabled CRTC (either by setting a NULL mode |
| 387 | * or just runtime disabled through DPMS respectively the new atomic |
Daniel Vetter | 4cba685 | 2015-12-08 09:49:20 +0100 | [diff] [blame] | 388 | * "ACTIVE" state) should result in an -EINVAL error code. Note that |
| 389 | * drm_atomic_helper_page_flip() checks this already for atomic drivers. |
Kristian Høgsberg | d91d8a3 | 2009-11-17 12:43:55 -0500 | [diff] [blame] | 390 | */ |
| 391 | int (*page_flip)(struct drm_crtc *crtc, |
| 392 | struct drm_framebuffer *fb, |
Keith Packard | ed8d197 | 2013-07-22 18:49:58 -0700 | [diff] [blame] | 393 | struct drm_pending_vblank_event *event, |
| 394 | uint32_t flags); |
Paulo Zanoni | bffd9de0 | 2012-05-15 18:09:05 -0300 | [diff] [blame] | 395 | |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 396 | /** |
Michel Dänzer | c229bfb | 2016-08-08 16:23:03 +0900 | [diff] [blame] | 397 | * @page_flip_target: |
| 398 | * |
| 399 | * Same as @page_flip but with an additional parameter specifying the |
| 400 | * absolute target vertical blank period (as reported by |
| 401 | * drm_crtc_vblank_count()) when the flip should take effect. |
| 402 | * |
| 403 | * Note that the core code calls drm_crtc_vblank_get before this entry |
| 404 | * point, and will call drm_crtc_vblank_put if this entry point returns |
| 405 | * any non-0 error code. It's the driver's responsibility to call |
| 406 | * drm_crtc_vblank_put after this entry point returns 0, typically when |
| 407 | * the flip completes. |
| 408 | */ |
| 409 | int (*page_flip_target)(struct drm_crtc *crtc, |
| 410 | struct drm_framebuffer *fb, |
| 411 | struct drm_pending_vblank_event *event, |
| 412 | uint32_t flags, uint32_t target); |
| 413 | |
| 414 | /** |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 415 | * @set_property: |
| 416 | * |
| 417 | * This is the legacy entry point to update a property attached to the |
| 418 | * CRTC. |
| 419 | * |
| 420 | * Drivers implementing atomic modeset should use |
| 421 | * drm_atomic_helper_crtc_set_property() to implement this hook. |
| 422 | * |
| 423 | * This callback is optional if the driver does not support any legacy |
| 424 | * driver-private properties. |
| 425 | * |
| 426 | * RETURNS: |
| 427 | * |
| 428 | * 0 on success or a negative error code on failure. |
| 429 | */ |
Paulo Zanoni | bffd9de0 | 2012-05-15 18:09:05 -0300 | [diff] [blame] | 430 | int (*set_property)(struct drm_crtc *crtc, |
| 431 | struct drm_property *property, uint64_t val); |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 432 | |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 433 | /** |
| 434 | * @atomic_duplicate_state: |
| 435 | * |
| 436 | * Duplicate the current atomic state for this CRTC and return it. |
| 437 | * The core and helpers gurantee that any atomic state duplicated with |
| 438 | * this hook and still owned by the caller (i.e. not transferred to the |
| 439 | * driver by calling ->atomic_commit() from struct |
| 440 | * &drm_mode_config_funcs) will be cleaned up by calling the |
| 441 | * @atomic_destroy_state hook in this structure. |
| 442 | * |
| 443 | * Atomic drivers which don't subclass struct &drm_crtc should use |
| 444 | * drm_atomic_helper_crtc_duplicate_state(). Drivers that subclass the |
| 445 | * state structure to extend it with driver-private state should use |
| 446 | * __drm_atomic_helper_crtc_duplicate_state() to make sure shared state is |
| 447 | * duplicated in a consistent fashion across drivers. |
| 448 | * |
| 449 | * It is an error to call this hook before crtc->state has been |
| 450 | * initialized correctly. |
| 451 | * |
| 452 | * NOTE: |
| 453 | * |
| 454 | * If the duplicate state references refcounted resources this hook must |
| 455 | * acquire a reference for each of them. The driver must release these |
| 456 | * references again in @atomic_destroy_state. |
| 457 | * |
| 458 | * RETURNS: |
| 459 | * |
| 460 | * Duplicated atomic state or NULL when the allocation failed. |
| 461 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 462 | struct drm_crtc_state *(*atomic_duplicate_state)(struct drm_crtc *crtc); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 463 | |
| 464 | /** |
| 465 | * @atomic_destroy_state: |
| 466 | * |
| 467 | * Destroy a state duplicated with @atomic_duplicate_state and release |
| 468 | * or unreference all resources it references |
| 469 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 470 | void (*atomic_destroy_state)(struct drm_crtc *crtc, |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 471 | struct drm_crtc_state *state); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 472 | |
| 473 | /** |
| 474 | * @atomic_set_property: |
| 475 | * |
| 476 | * Decode a driver-private property value and store the decoded value |
| 477 | * into the passed-in state structure. Since the atomic core decodes all |
| 478 | * standardized properties (even for extensions beyond the core set of |
| 479 | * properties which might not be implemented by all drivers) this |
| 480 | * requires drivers to subclass the state structure. |
| 481 | * |
| 482 | * Such driver-private properties should really only be implemented for |
| 483 | * truly hardware/vendor specific state. Instead it is preferred to |
| 484 | * standardize atomic extension and decode the properties used to expose |
| 485 | * such an extension in the core. |
| 486 | * |
| 487 | * Do not call this function directly, use |
| 488 | * drm_atomic_crtc_set_property() instead. |
| 489 | * |
| 490 | * This callback is optional if the driver does not support any |
| 491 | * driver-private atomic properties. |
| 492 | * |
| 493 | * NOTE: |
| 494 | * |
| 495 | * This function is called in the state assembly phase of atomic |
| 496 | * modesets, which can be aborted for any reason (including on |
| 497 | * userspace's request to just check whether a configuration would be |
| 498 | * possible). Drivers MUST NOT touch any persistent state (hardware or |
| 499 | * software) or data structures except the passed in @state parameter. |
| 500 | * |
| 501 | * Also since userspace controls in which order properties are set this |
| 502 | * function must not do any input validation (since the state update is |
| 503 | * incomplete and hence likely inconsistent). Instead any such input |
| 504 | * validation must be done in the various atomic_check callbacks. |
| 505 | * |
| 506 | * RETURNS: |
| 507 | * |
| 508 | * 0 if the property has been found, -EINVAL if the property isn't |
| 509 | * implemented by the driver (which should never happen, the core only |
| 510 | * asks for properties attached to this CRTC). No other validation is |
| 511 | * allowed by the driver. The core already checks that the property |
| 512 | * value is within the range (integer, valid enum value, ...) the driver |
| 513 | * set when registering the property. |
| 514 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 515 | int (*atomic_set_property)(struct drm_crtc *crtc, |
| 516 | struct drm_crtc_state *state, |
| 517 | struct drm_property *property, |
| 518 | uint64_t val); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 519 | /** |
| 520 | * @atomic_get_property: |
| 521 | * |
| 522 | * Reads out the decoded driver-private property. This is used to |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 523 | * implement the GETCRTC IOCTL. |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 524 | * |
| 525 | * Do not call this function directly, use |
| 526 | * drm_atomic_crtc_get_property() instead. |
| 527 | * |
| 528 | * This callback is optional if the driver does not support any |
| 529 | * driver-private atomic properties. |
| 530 | * |
| 531 | * RETURNS: |
| 532 | * |
| 533 | * 0 on success, -EINVAL if the property isn't implemented by the |
| 534 | * driver (which should never happen, the core only asks for |
| 535 | * properties attached to this CRTC). |
| 536 | */ |
Rob Clark | ac9c925 | 2014-12-18 16:01:47 -0500 | [diff] [blame] | 537 | int (*atomic_get_property)(struct drm_crtc *crtc, |
| 538 | const struct drm_crtc_state *state, |
| 539 | struct drm_property *property, |
| 540 | uint64_t *val); |
Benjamin Gaignard | 79190ea | 2016-06-21 16:37:09 +0200 | [diff] [blame] | 541 | |
| 542 | /** |
| 543 | * @late_register: |
| 544 | * |
| 545 | * This optional hook can be used to register additional userspace |
| 546 | * interfaces attached to the crtc like debugfs interfaces. |
| 547 | * It is called late in the driver load sequence from drm_dev_register(). |
| 548 | * Everything added from this callback should be unregistered in |
| 549 | * the early_unregister callback. |
| 550 | * |
| 551 | * Returns: |
| 552 | * |
| 553 | * 0 on success, or a negative error code on failure. |
| 554 | */ |
| 555 | int (*late_register)(struct drm_crtc *crtc); |
| 556 | |
| 557 | /** |
| 558 | * @early_unregister: |
| 559 | * |
| 560 | * This optional hook should be used to unregister the additional |
| 561 | * userspace interfaces attached to the crtc from |
| 562 | * late_unregister(). It is called from drm_dev_unregister(), |
| 563 | * early in the driver unload sequence to disable userspace access |
| 564 | * before data structures are torndown. |
| 565 | */ |
| 566 | void (*early_unregister)(struct drm_crtc *crtc); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 567 | }; |
| 568 | |
| 569 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 570 | * struct drm_crtc - central CRTC control structure |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 571 | * @dev: parent DRM device |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 572 | * @port: OF node used by drm_of_find_possible_crtcs() |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 573 | * @head: list management |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 574 | * @name: human readable name, can be overwritten by the driver |
Rob Clark | 51fd371 | 2013-11-19 12:10:12 -0500 | [diff] [blame] | 575 | * @mutex: per-CRTC locking |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 576 | * @base: base KMS object for ID tracking etc. |
Matt Roper | e13161a | 2014-04-01 15:22:38 -0700 | [diff] [blame] | 577 | * @primary: primary plane for this CRTC |
| 578 | * @cursor: cursor plane for this CRTC |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 579 | * @cursor_x: current x position of the cursor, used for universal cursor planes |
| 580 | * @cursor_y: current y position of the cursor, used for universal cursor planes |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 581 | * @enabled: is this CRTC enabled? |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 582 | * @mode: current mode timings |
| 583 | * @hwmode: mode timings as programmed to hw regs |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 584 | * @x: x position on screen |
| 585 | * @y: y position on screen |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 586 | * @funcs: CRTC control functions |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 587 | * @gamma_size: size of gamma ramp |
| 588 | * @gamma_store: gamma ramp values |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 589 | * @helper_private: mid-layer private data |
Paulo Zanoni | bffd9de0 | 2012-05-15 18:09:05 -0300 | [diff] [blame] | 590 | * @properties: property tracking for this CRTC |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 591 | * |
| 592 | * Each CRTC may have one or more connectors associated with it. This structure |
| 593 | * allows the CRTC to be controlled. |
| 594 | */ |
| 595 | struct drm_crtc { |
| 596 | struct drm_device *dev; |
Russell King | 7e435aa | 2014-06-15 11:07:12 +0100 | [diff] [blame] | 597 | struct device_node *port; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 598 | struct list_head head; |
| 599 | |
Ville Syrjälä | fa3ab4c | 2015-12-08 18:41:53 +0200 | [diff] [blame] | 600 | char *name; |
| 601 | |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 602 | /** |
| 603 | * @mutex: |
Daniel Vetter | 29494c1 | 2012-12-02 02:18:25 +0100 | [diff] [blame] | 604 | * |
| 605 | * This provides a read lock for the overall crtc state (mode, dpms |
| 606 | * state, ...) and a write lock for everything which can be update |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 607 | * without a full modeset (fb, cursor data, crtc properties ...). Full |
| 608 | * modeset also need to grab dev->mode_config.connection_mutex. |
Daniel Vetter | 29494c1 | 2012-12-02 02:18:25 +0100 | [diff] [blame] | 609 | */ |
Rob Clark | 51fd371 | 2013-11-19 12:10:12 -0500 | [diff] [blame] | 610 | struct drm_modeset_lock mutex; |
Daniel Vetter | 29494c1 | 2012-12-02 02:18:25 +0100 | [diff] [blame] | 611 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 612 | struct drm_mode_object base; |
| 613 | |
Matt Roper | e13161a | 2014-04-01 15:22:38 -0700 | [diff] [blame] | 614 | /* primary and cursor planes for CRTC */ |
| 615 | struct drm_plane *primary; |
| 616 | struct drm_plane *cursor; |
| 617 | |
Daniel Vetter | 9609408 | 2016-07-15 21:47:59 +0200 | [diff] [blame] | 618 | /** |
| 619 | * @index: Position inside the mode_config.list, can be used as an array |
| 620 | * index. It is invariant over the lifetime of the CRTC. |
| 621 | */ |
Chris Wilson | 490d3d1 | 2016-05-27 20:05:00 +0100 | [diff] [blame] | 622 | unsigned index; |
| 623 | |
Matt Roper | 161d0dc | 2014-06-10 08:28:10 -0700 | [diff] [blame] | 624 | /* position of cursor plane on crtc */ |
| 625 | int cursor_x; |
| 626 | int cursor_y; |
| 627 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 628 | bool enabled; |
| 629 | |
Mario Kleiner | 27641c3 | 2010-10-23 04:20:23 +0200 | [diff] [blame] | 630 | /* Requested mode from modesetting. */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 631 | struct drm_display_mode mode; |
| 632 | |
Mario Kleiner | 27641c3 | 2010-10-23 04:20:23 +0200 | [diff] [blame] | 633 | /* Programmed mode in hw, after adjustments for encoders, |
| 634 | * crtc, panel scaling etc. Needed for timestamping etc. |
| 635 | */ |
| 636 | struct drm_display_mode hwmode; |
| 637 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 638 | int x, y; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 639 | const struct drm_crtc_funcs *funcs; |
| 640 | |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 641 | /* Legacy FB CRTC gamma size for reporting to userspace */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 642 | uint32_t gamma_size; |
| 643 | uint16_t *gamma_store; |
| 644 | |
| 645 | /* if you are using the helper */ |
Daniel Vetter | 4490d4c | 2015-12-04 09:45:45 +0100 | [diff] [blame] | 646 | const struct drm_crtc_helper_funcs *helper_private; |
Paulo Zanoni | bffd9de0 | 2012-05-15 18:09:05 -0300 | [diff] [blame] | 647 | |
| 648 | struct drm_object_properties properties; |
Daniel Vetter | d059f65 | 2014-07-25 18:07:40 +0200 | [diff] [blame] | 649 | |
Daniel Vetter | 3b24f7d | 2016-06-08 14:19:00 +0200 | [diff] [blame] | 650 | /** |
| 651 | * @state: |
| 652 | * |
| 653 | * Current atomic state for this CRTC. |
| 654 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 655 | struct drm_crtc_state *state; |
| 656 | |
Daniel Vetter | 3b24f7d | 2016-06-08 14:19:00 +0200 | [diff] [blame] | 657 | /** |
| 658 | * @commit_list: |
| 659 | * |
| 660 | * List of &drm_crtc_commit structures tracking pending commits. |
| 661 | * Protected by @commit_lock. This list doesn't hold its own full |
| 662 | * reference, but burrows it from the ongoing commit. Commit entries |
| 663 | * must be removed from this list once the commit is fully completed, |
| 664 | * but before it's correspoding &drm_atomic_state gets destroyed. |
| 665 | */ |
| 666 | struct list_head commit_list; |
| 667 | |
| 668 | /** |
| 669 | * @commit_lock: |
| 670 | * |
| 671 | * Spinlock to protect @commit_list. |
| 672 | */ |
| 673 | spinlock_t commit_lock; |
| 674 | |
| 675 | /** |
| 676 | * @acquire_ctx: |
| 677 | * |
| 678 | * Per-CRTC implicit acquire context used by atomic drivers for legacy |
| 679 | * IOCTLs, so that atomic drivers can get at the locking acquire |
| 680 | * context. |
Daniel Vetter | d059f65 | 2014-07-25 18:07:40 +0200 | [diff] [blame] | 681 | */ |
| 682 | struct drm_modeset_acquire_ctx *acquire_ctx; |
Gustavo Padovan | 2a38015 | 2016-11-15 23:37:08 +0900 | [diff] [blame] | 683 | |
| 684 | /** |
| 685 | * @fence_context: |
| 686 | * |
| 687 | * timeline context used for fence operations. |
| 688 | */ |
| 689 | unsigned int fence_context; |
| 690 | |
| 691 | /** |
| 692 | * @fence_lock: |
| 693 | * |
| 694 | * spinlock to protect the fences in the fence_context. |
| 695 | */ |
| 696 | |
| 697 | spinlock_t fence_lock; |
| 698 | /** |
| 699 | * @fence_seqno: |
| 700 | * |
| 701 | * Seqno variable used as monotonic counter for the fences |
| 702 | * created on the CRTC's timeline. |
| 703 | */ |
| 704 | unsigned long fence_seqno; |
| 705 | |
| 706 | /** |
| 707 | * @timeline_name: |
| 708 | * |
| 709 | * The name of the CRTC's fence timeline. |
| 710 | */ |
| 711 | char timeline_name[32]; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 712 | }; |
| 713 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 714 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 715 | * struct drm_mode_set - new values for a CRTC config change |
Jesse Barnes | ef27351 | 2011-11-07 12:03:19 -0800 | [diff] [blame] | 716 | * @fb: framebuffer to use for new config |
| 717 | * @crtc: CRTC whose configuration we're about to change |
| 718 | * @mode: mode timings to use |
| 719 | * @x: position of this CRTC relative to @fb |
| 720 | * @y: position of this CRTC relative to @fb |
| 721 | * @connectors: array of connectors to drive with this CRTC if possible |
| 722 | * @num_connectors: size of @connectors array |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 723 | * |
| 724 | * Represents a single crtc the connectors that it drives with what mode |
| 725 | * and from which framebuffer it scans out from. |
| 726 | * |
| 727 | * This is used to set modes. |
| 728 | */ |
| 729 | struct drm_mode_set { |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 730 | struct drm_framebuffer *fb; |
| 731 | struct drm_crtc *crtc; |
| 732 | struct drm_display_mode *mode; |
| 733 | |
| 734 | uint32_t x; |
| 735 | uint32_t y; |
| 736 | |
| 737 | struct drm_connector **connectors; |
| 738 | size_t num_connectors; |
| 739 | }; |
| 740 | |
| 741 | /** |
Jesse Barnes | 550cebc | 2011-11-07 12:03:20 -0800 | [diff] [blame] | 742 | * struct drm_mode_config_funcs - basic driver provided mode setting functions |
Jesse Barnes | 550cebc | 2011-11-07 12:03:20 -0800 | [diff] [blame] | 743 | * |
| 744 | * Some global (i.e. not per-CRTC, connector, etc) mode setting functions that |
| 745 | * involve drivers. |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 746 | */ |
| 747 | struct drm_mode_config_funcs { |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 748 | /** |
| 749 | * @fb_create: |
| 750 | * |
| 751 | * Create a new framebuffer object. The core does basic checks on the |
| 752 | * requested metadata, but most of that is left to the driver. See |
| 753 | * struct &drm_mode_fb_cmd2 for details. |
| 754 | * |
Daniel Vetter | d55f532 | 2015-12-08 09:49:19 +0100 | [diff] [blame] | 755 | * If the parameters are deemed valid and the backing storage objects in |
| 756 | * the underlying memory manager all exist, then the driver allocates |
| 757 | * a new &drm_framebuffer structure, subclassed to contain |
| 758 | * driver-specific information (like the internal native buffer object |
| 759 | * references). It also needs to fill out all relevant metadata, which |
| 760 | * should be done by calling drm_helper_mode_fill_fb_struct(). |
| 761 | * |
| 762 | * The initialization is finalized by calling drm_framebuffer_init(), |
| 763 | * which registers the framebuffer and makes it accessible to other |
| 764 | * threads. |
| 765 | * |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 766 | * RETURNS: |
| 767 | * |
| 768 | * A new framebuffer with an initial reference count of 1 or a negative |
| 769 | * error code encoded with ERR_PTR(). |
| 770 | */ |
Jesse Barnes | 550cebc | 2011-11-07 12:03:20 -0800 | [diff] [blame] | 771 | struct drm_framebuffer *(*fb_create)(struct drm_device *dev, |
| 772 | struct drm_file *file_priv, |
Ville Syrjälä | 1eb8345 | 2015-11-11 19:11:29 +0200 | [diff] [blame] | 773 | const struct drm_mode_fb_cmd2 *mode_cmd); |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 774 | |
| 775 | /** |
| 776 | * @output_poll_changed: |
| 777 | * |
| 778 | * Callback used by helpers to inform the driver of output configuration |
| 779 | * changes. |
| 780 | * |
| 781 | * Drivers implementing fbdev emulation with the helpers can call |
| 782 | * drm_fb_helper_hotplug_changed from this hook to inform the fbdev |
| 783 | * helper of output changes. |
| 784 | * |
| 785 | * FIXME: |
| 786 | * |
| 787 | * Except that there's no vtable for device-level helper callbacks |
| 788 | * there's no reason this is a core function. |
| 789 | */ |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 790 | void (*output_poll_changed)(struct drm_device *dev); |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 791 | |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 792 | /** |
| 793 | * @atomic_check: |
| 794 | * |
| 795 | * This is the only hook to validate an atomic modeset update. This |
| 796 | * function must reject any modeset and state changes which the hardware |
| 797 | * or driver doesn't support. This includes but is of course not limited |
| 798 | * to: |
| 799 | * |
| 800 | * - Checking that the modes, framebuffers, scaling and placement |
| 801 | * requirements and so on are within the limits of the hardware. |
| 802 | * |
| 803 | * - Checking that any hidden shared resources are not oversubscribed. |
| 804 | * This can be shared PLLs, shared lanes, overall memory bandwidth, |
| 805 | * display fifo space (where shared between planes or maybe even |
| 806 | * CRTCs). |
| 807 | * |
| 808 | * - Checking that virtualized resources exported to userspace are not |
| 809 | * oversubscribed. For various reasons it can make sense to expose |
| 810 | * more planes, crtcs or encoders than which are physically there. One |
| 811 | * example is dual-pipe operations (which generally should be hidden |
| 812 | * from userspace if when lockstepped in hardware, exposed otherwise), |
| 813 | * where a plane might need 1 hardware plane (if it's just on one |
| 814 | * pipe), 2 hardware planes (when it spans both pipes) or maybe even |
| 815 | * shared a hardware plane with a 2nd plane (if there's a compatible |
| 816 | * plane requested on the area handled by the other pipe). |
| 817 | * |
| 818 | * - Check that any transitional state is possible and that if |
| 819 | * requested, the update can indeed be done in the vblank period |
| 820 | * without temporarily disabling some functions. |
| 821 | * |
| 822 | * - Check any other constraints the driver or hardware might have. |
| 823 | * |
| 824 | * - This callback also needs to correctly fill out the &drm_crtc_state |
| 825 | * in this update to make sure that drm_atomic_crtc_needs_modeset() |
| 826 | * reflects the nature of the possible update and returns true if and |
| 827 | * only if the update cannot be applied without tearing within one |
| 828 | * vblank on that CRTC. The core uses that information to reject |
| 829 | * updates which require a full modeset (i.e. blanking the screen, or |
| 830 | * at least pausing updates for a substantial amount of time) if |
| 831 | * userspace has disallowed that in its request. |
| 832 | * |
| 833 | * - The driver also does not need to repeat basic input validation |
| 834 | * like done for the corresponding legacy entry points. The core does |
| 835 | * that before calling this hook. |
| 836 | * |
| 837 | * See the documentation of @atomic_commit for an exhaustive list of |
| 838 | * error conditions which don't have to be checked at the |
| 839 | * ->atomic_check() stage? |
| 840 | * |
| 841 | * See the documentation for struct &drm_atomic_state for how exactly |
| 842 | * an atomic modeset update is described. |
| 843 | * |
| 844 | * Drivers using the atomic helpers can implement this hook using |
| 845 | * drm_atomic_helper_check(), or one of the exported sub-functions of |
| 846 | * it. |
| 847 | * |
| 848 | * RETURNS: |
| 849 | * |
| 850 | * 0 on success or one of the below negative error codes: |
| 851 | * |
| 852 | * - -EINVAL, if any of the above constraints are violated. |
| 853 | * |
| 854 | * - -EDEADLK, when returned from an attempt to acquire an additional |
| 855 | * &drm_modeset_lock through drm_modeset_lock(). |
| 856 | * |
| 857 | * - -ENOMEM, if allocating additional state sub-structures failed due |
| 858 | * to lack of memory. |
| 859 | * |
| 860 | * - -EINTR, -EAGAIN or -ERESTARTSYS, if the IOCTL should be restarted. |
| 861 | * This can either be due to a pending signal, or because the driver |
| 862 | * needs to completely bail out to recover from an exceptional |
| 863 | * situation like a GPU hang. From a userspace point all errors are |
| 864 | * treated equally. |
| 865 | */ |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 866 | int (*atomic_check)(struct drm_device *dev, |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 867 | struct drm_atomic_state *state); |
| 868 | |
| 869 | /** |
| 870 | * @atomic_commit: |
| 871 | * |
| 872 | * This is the only hook to commit an atomic modeset update. The core |
| 873 | * guarantees that @atomic_check has been called successfully before |
| 874 | * calling this function, and that nothing has been changed in the |
| 875 | * interim. |
| 876 | * |
| 877 | * See the documentation for struct &drm_atomic_state for how exactly |
| 878 | * an atomic modeset update is described. |
| 879 | * |
| 880 | * Drivers using the atomic helpers can implement this hook using |
| 881 | * drm_atomic_helper_commit(), or one of the exported sub-functions of |
| 882 | * it. |
| 883 | * |
Maarten Lankhorst | 286dbb8 | 2016-04-26 16:11:34 +0200 | [diff] [blame] | 884 | * Nonblocking commits (as indicated with the nonblock parameter) must |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 885 | * do any preparatory work which might result in an unsuccessful commit |
| 886 | * in the context of this callback. The only exceptions are hardware |
| 887 | * errors resulting in -EIO. But even in that case the driver must |
| 888 | * ensure that the display pipe is at least running, to avoid |
| 889 | * compositors crashing when pageflips don't work. Anything else, |
| 890 | * specifically committing the update to the hardware, should be done |
| 891 | * without blocking the caller. For updates which do not require a |
| 892 | * modeset this must be guaranteed. |
| 893 | * |
| 894 | * The driver must wait for any pending rendering to the new |
| 895 | * framebuffers to complete before executing the flip. It should also |
| 896 | * wait for any pending rendering from other drivers if the underlying |
Maarten Lankhorst | 286dbb8 | 2016-04-26 16:11:34 +0200 | [diff] [blame] | 897 | * buffer is a shared dma-buf. Nonblocking commits must not wait for |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 898 | * rendering in the context of this callback. |
| 899 | * |
| 900 | * An application can request to be notified when the atomic commit has |
| 901 | * completed. These events are per-CRTC and can be distinguished by the |
| 902 | * CRTC index supplied in &drm_event to userspace. |
| 903 | * |
| 904 | * The drm core will supply a struct &drm_event in the event |
Daniel Vetter | 6180213 | 2016-09-30 12:04:56 +0200 | [diff] [blame] | 905 | * member of each CRTC's &drm_crtc_state structure. See the |
| 906 | * documentation for &drm_crtc_state for more details about the precise |
| 907 | * semantics of this event. |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 908 | * |
| 909 | * NOTE: |
| 910 | * |
| 911 | * Drivers are not allowed to shut down any display pipe successfully |
| 912 | * enabled through an atomic commit on their own. Doing so can result in |
| 913 | * compositors crashing if a page flip is suddenly rejected because the |
| 914 | * pipe is off. |
| 915 | * |
| 916 | * RETURNS: |
| 917 | * |
| 918 | * 0 on success or one of the below negative error codes: |
| 919 | * |
Maarten Lankhorst | 286dbb8 | 2016-04-26 16:11:34 +0200 | [diff] [blame] | 920 | * - -EBUSY, if a nonblocking updated is requested and there is |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 921 | * an earlier updated pending. Drivers are allowed to support a queue |
| 922 | * of outstanding updates, but currently no driver supports that. |
| 923 | * Note that drivers must wait for preceding updates to complete if a |
| 924 | * synchronous update is requested, they are not allowed to fail the |
| 925 | * commit in that case. |
| 926 | * |
| 927 | * - -ENOMEM, if the driver failed to allocate memory. Specifically |
| 928 | * this can happen when trying to pin framebuffers, which must only |
| 929 | * be done when committing the state. |
| 930 | * |
| 931 | * - -ENOSPC, as a refinement of the more generic -ENOMEM to indicate |
| 932 | * that the driver has run out of vram, iommu space or similar GPU |
| 933 | * address space needed for framebuffer. |
| 934 | * |
| 935 | * - -EIO, if the hardware completely died. |
| 936 | * |
| 937 | * - -EINTR, -EAGAIN or -ERESTARTSYS, if the IOCTL should be restarted. |
| 938 | * This can either be due to a pending signal, or because the driver |
| 939 | * needs to completely bail out to recover from an exceptional |
| 940 | * situation like a GPU hang. From a userspace point of view all errors are |
| 941 | * treated equally. |
| 942 | * |
| 943 | * This list is exhaustive. Specifically this hook is not allowed to |
| 944 | * return -EINVAL (any invalid requests should be caught in |
| 945 | * @atomic_check) or -EDEADLK (this function must not acquire |
| 946 | * additional modeset locks). |
| 947 | */ |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 948 | int (*atomic_commit)(struct drm_device *dev, |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 949 | struct drm_atomic_state *state, |
Maarten Lankhorst | 286dbb8 | 2016-04-26 16:11:34 +0200 | [diff] [blame] | 950 | bool nonblock); |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 951 | |
| 952 | /** |
| 953 | * @atomic_state_alloc: |
| 954 | * |
| 955 | * This optional hook can be used by drivers that want to subclass struct |
| 956 | * &drm_atomic_state to be able to track their own driver-private global |
| 957 | * state easily. If this hook is implemented, drivers must also |
| 958 | * implement @atomic_state_clear and @atomic_state_free. |
| 959 | * |
| 960 | * RETURNS: |
| 961 | * |
| 962 | * A new &drm_atomic_state on success or NULL on failure. |
| 963 | */ |
Maarten Lankhorst | 036ef57 | 2015-05-18 10:06:40 +0200 | [diff] [blame] | 964 | struct drm_atomic_state *(*atomic_state_alloc)(struct drm_device *dev); |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 965 | |
| 966 | /** |
| 967 | * @atomic_state_clear: |
| 968 | * |
| 969 | * This hook must clear any driver private state duplicated into the |
| 970 | * passed-in &drm_atomic_state. This hook is called when the caller |
| 971 | * encountered a &drm_modeset_lock deadlock and needs to drop all |
| 972 | * already acquired locks as part of the deadlock avoidance dance |
| 973 | * implemented in drm_modeset_lock_backoff(). |
| 974 | * |
| 975 | * Any duplicated state must be invalidated since a concurrent atomic |
| 976 | * update might change it, and the drm atomic interfaces always apply |
| 977 | * updates as relative changes to the current state. |
| 978 | * |
| 979 | * Drivers that implement this must call drm_atomic_state_default_clear() |
| 980 | * to clear common state. |
| 981 | */ |
Maarten Lankhorst | 036ef57 | 2015-05-18 10:06:40 +0200 | [diff] [blame] | 982 | void (*atomic_state_clear)(struct drm_atomic_state *state); |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 983 | |
| 984 | /** |
| 985 | * @atomic_state_free: |
| 986 | * |
| 987 | * This hook needs driver private resources and the &drm_atomic_state |
| 988 | * itself. Note that the core first calls drm_atomic_state_clear() to |
| 989 | * avoid code duplicate between the clear and free hooks. |
| 990 | * |
| 991 | * Drivers that implement this must call drm_atomic_state_default_free() |
| 992 | * to release common resources. |
| 993 | */ |
Maarten Lankhorst | 036ef57 | 2015-05-18 10:06:40 +0200 | [diff] [blame] | 994 | void (*atomic_state_free)(struct drm_atomic_state *state); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 995 | }; |
| 996 | |
Jesse Barnes | c1aaca2 | 2011-11-07 12:03:21 -0800 | [diff] [blame] | 997 | /** |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 998 | * struct drm_mode_config - Mode configuration control structure |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 999 | * @mutex: mutex protecting KMS related lists and structures |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1000 | * @connection_mutex: ww mutex protecting connector state and routing |
| 1001 | * @acquire_ctx: global implicit acquire context used by atomic drivers for |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 1002 | * legacy IOCTLs |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1003 | * @fb_lock: mutex to protect fb state and lists |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 1004 | * @num_fb: number of fbs available |
| 1005 | * @fb_list: list of framebuffers available |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 1006 | * @num_encoder: number of encoders on this device |
| 1007 | * @encoder_list: list of encoder objects |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1008 | * @num_overlay_plane: number of overlay planes on this device |
| 1009 | * @num_total_plane: number of universal (i.e. with primary/curso) planes on this device |
| 1010 | * @plane_list: list of plane objects |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 1011 | * @num_crtc: number of CRTCs on this device |
| 1012 | * @crtc_list: list of CRTC objects |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1013 | * @property_list: list of property objects |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 1014 | * @min_width: minimum pixel width on this device |
| 1015 | * @min_height: minimum pixel height on this device |
| 1016 | * @max_width: maximum pixel width on this device |
| 1017 | * @max_height: maximum pixel height on this device |
| 1018 | * @funcs: core driver provided mode setting functions |
| 1019 | * @fb_base: base address of the framebuffer |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1020 | * @poll_enabled: track polling support for this device |
| 1021 | * @poll_running: track polling status for this device |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 1022 | * @delayed_event: track delayed poll uevent deliver for this device |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 1023 | * @output_poll_work: delayed work for polling in process context |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1024 | * @property_blob_list: list of all the blob property objects |
Daniel Stone | 8fb6e7a | 2015-04-20 19:22:54 +0100 | [diff] [blame] | 1025 | * @blob_lock: mutex for blob property allocation and management |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 1026 | * @*_property: core property tracking |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1027 | * @preferred_depth: preferred RBG pixel depth, used by fb helpers |
| 1028 | * @prefer_shadow: hint to userspace to prefer shadow-fb rendering |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1029 | * @cursor_width: hint to userspace for max cursor width |
| 1030 | * @cursor_height: hint to userspace for max cursor height |
Daniel Vetter | 9f2a795 | 2016-06-08 14:19:02 +0200 | [diff] [blame] | 1031 | * @helper_private: mid-layer private data |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1032 | * |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 1033 | * Core mode resource tracking structure. All CRTC, encoders, and connectors |
| 1034 | * enumerated by the driver are added here, as are global properties. Some |
| 1035 | * global restrictions are also here, e.g. dimension restrictions. |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1036 | */ |
| 1037 | struct drm_mode_config { |
Jesse Barnes | ad2563c | 2009-01-19 17:21:45 +1000 | [diff] [blame] | 1038 | struct mutex mutex; /* protects configuration (mode lists etc.) */ |
Rob Clark | 51fd371 | 2013-11-19 12:10:12 -0500 | [diff] [blame] | 1039 | struct drm_modeset_lock connection_mutex; /* protects connector->encoder and encoder->crtc links */ |
| 1040 | struct drm_modeset_acquire_ctx *acquire_ctx; /* for legacy _lock_all() / _unlock_all() */ |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 1041 | |
| 1042 | /** |
| 1043 | * @idr_mutex: |
| 1044 | * |
| 1045 | * Mutex for KMS ID allocation and management. Protects both @crtc_idr |
| 1046 | * and @tile_idr. |
| 1047 | */ |
| 1048 | struct mutex idr_mutex; |
| 1049 | |
| 1050 | /** |
| 1051 | * @crtc_idr: |
| 1052 | * |
| 1053 | * Main KMS ID tracking object. Use this idr for all IDs, fb, crtc, |
| 1054 | * connector, modes - just makes life easier to have only one. |
| 1055 | */ |
| 1056 | struct idr crtc_idr; |
| 1057 | |
| 1058 | /** |
| 1059 | * @tile_idr: |
| 1060 | * |
| 1061 | * Use this idr for allocating new IDs for tiled sinks like use in some |
| 1062 | * high-res DP MST screens. |
| 1063 | */ |
| 1064 | struct idr tile_idr; |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1065 | |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1066 | struct mutex fb_lock; /* proctects global and per-file fb lists */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1067 | int num_fb; |
| 1068 | struct list_head fb_list; |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1069 | |
Daniel Vetter | 9609408 | 2016-07-15 21:47:59 +0200 | [diff] [blame] | 1070 | /** |
| 1071 | * @num_connector: Number of connectors on this device. |
| 1072 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1073 | int num_connector; |
Daniel Vetter | 9609408 | 2016-07-15 21:47:59 +0200 | [diff] [blame] | 1074 | /** |
| 1075 | * @connector_ida: ID allocator for connector indices. |
| 1076 | */ |
Maarten Lankhorst | 5fff80b | 2016-02-17 08:32:05 +0100 | [diff] [blame] | 1077 | struct ida connector_ida; |
Daniel Vetter | 9609408 | 2016-07-15 21:47:59 +0200 | [diff] [blame] | 1078 | /** |
| 1079 | * @connector_list: List of connector objects. |
| 1080 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1081 | struct list_head connector_list; |
| 1082 | int num_encoder; |
| 1083 | struct list_head encoder_list; |
Matt Roper | e27dde3 | 2014-04-01 15:22:30 -0700 | [diff] [blame] | 1084 | |
| 1085 | /* |
| 1086 | * Track # of overlay planes separately from # of total planes. By |
| 1087 | * default we only advertise overlay planes to userspace; if userspace |
| 1088 | * sets the "universal plane" capability bit, we'll go ahead and |
| 1089 | * expose all planes. |
| 1090 | */ |
| 1091 | int num_overlay_plane; |
| 1092 | int num_total_plane; |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1093 | struct list_head plane_list; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1094 | |
| 1095 | int num_crtc; |
| 1096 | struct list_head crtc_list; |
| 1097 | |
| 1098 | struct list_head property_list; |
| 1099 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1100 | int min_width, min_height; |
| 1101 | int max_width, max_height; |
Laurent Pinchart | e6ecefa | 2012-05-17 13:27:23 +0200 | [diff] [blame] | 1102 | const struct drm_mode_config_funcs *funcs; |
Benjamin Herrenschmidt | d883f7f | 2009-02-02 16:55:45 +1100 | [diff] [blame] | 1103 | resource_size_t fb_base; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1104 | |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 1105 | /* output poll support */ |
| 1106 | bool poll_enabled; |
Daniel Vetter | 905bc9f | 2012-10-23 18:23:36 +0000 | [diff] [blame] | 1107 | bool poll_running; |
Daniel Vetter | 162b6a5 | 2015-01-21 08:45:21 +0100 | [diff] [blame] | 1108 | bool delayed_event; |
Tejun Heo | 991ea75 | 2010-07-20 22:09:02 +0200 | [diff] [blame] | 1109 | struct delayed_work output_poll_work; |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 1110 | |
Daniel Stone | 8fb6e7a | 2015-04-20 19:22:54 +0100 | [diff] [blame] | 1111 | struct mutex blob_lock; |
| 1112 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1113 | /* pointers to standard properties */ |
| 1114 | struct list_head property_blob_list; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1115 | /** |
| 1116 | * @edid_property: Default connector property to hold the EDID of the |
| 1117 | * currently connected sink, if any. |
| 1118 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1119 | struct drm_property *edid_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1120 | /** |
| 1121 | * @dpms_property: Default connector property to control the |
| 1122 | * connector's DPMS state. |
| 1123 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1124 | struct drm_property *dpms_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1125 | /** |
| 1126 | * @path_property: Default connector property to hold the DP MST path |
| 1127 | * for the port. |
| 1128 | */ |
Dave Airlie | 43aba7e | 2014-06-05 14:01:31 +1000 | [diff] [blame] | 1129 | struct drm_property *path_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1130 | /** |
| 1131 | * @tile_property: Default connector property to store the tile |
| 1132 | * position of a tiled screen, for sinks which need to be driven with |
| 1133 | * multiple CRTCs. |
| 1134 | */ |
Dave Airlie | 6f134d7 | 2014-10-20 16:30:50 +1000 | [diff] [blame] | 1135 | struct drm_property *tile_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1136 | /** |
| 1137 | * @plane_type_property: Default plane property to differentiate |
| 1138 | * CURSOR, PRIMARY and OVERLAY legacy uses of planes. |
| 1139 | */ |
Rob Clark | 9922ab5 | 2014-04-01 20:16:57 -0400 | [diff] [blame] | 1140 | struct drm_property *plane_type_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1141 | /** |
| 1142 | * @rotation_property: Optional property for planes or CRTCs to specifiy |
| 1143 | * rotation. |
| 1144 | */ |
Sonika Jindal | 2a297cc | 2014-08-05 11:26:54 +0530 | [diff] [blame] | 1145 | struct drm_property *rotation_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1146 | /** |
| 1147 | * @prop_src_x: Default atomic plane property for the plane source |
| 1148 | * position in the connected &drm_framebuffer. |
| 1149 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1150 | struct drm_property *prop_src_x; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1151 | /** |
| 1152 | * @prop_src_y: Default atomic plane property for the plane source |
| 1153 | * position in the connected &drm_framebuffer. |
| 1154 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1155 | struct drm_property *prop_src_y; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1156 | /** |
| 1157 | * @prop_src_w: Default atomic plane property for the plane source |
| 1158 | * position in the connected &drm_framebuffer. |
| 1159 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1160 | struct drm_property *prop_src_w; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1161 | /** |
| 1162 | * @prop_src_h: Default atomic plane property for the plane source |
| 1163 | * position in the connected &drm_framebuffer. |
| 1164 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1165 | struct drm_property *prop_src_h; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1166 | /** |
| 1167 | * @prop_crtc_x: Default atomic plane property for the plane destination |
| 1168 | * position in the &drm_crtc is is being shown on. |
| 1169 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1170 | struct drm_property *prop_crtc_x; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1171 | /** |
| 1172 | * @prop_crtc_y: Default atomic plane property for the plane destination |
| 1173 | * position in the &drm_crtc is is being shown on. |
| 1174 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1175 | struct drm_property *prop_crtc_y; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1176 | /** |
| 1177 | * @prop_crtc_w: Default atomic plane property for the plane destination |
| 1178 | * position in the &drm_crtc is is being shown on. |
| 1179 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1180 | struct drm_property *prop_crtc_w; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1181 | /** |
| 1182 | * @prop_crtc_h: Default atomic plane property for the plane destination |
| 1183 | * position in the &drm_crtc is is being shown on. |
| 1184 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1185 | struct drm_property *prop_crtc_h; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1186 | /** |
| 1187 | * @prop_fb_id: Default atomic plane property to specify the |
| 1188 | * &drm_framebuffer. |
| 1189 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1190 | struct drm_property *prop_fb_id; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1191 | /** |
Gustavo Padovan | 96e02f4 | 2016-11-15 22:06:39 +0900 | [diff] [blame] | 1192 | * @prop_in_fence_fd: Sync File fd representing the incoming fences |
| 1193 | * for a Plane. |
| 1194 | */ |
| 1195 | struct drm_property *prop_in_fence_fd; |
| 1196 | /** |
Gustavo Padovan | 710c1ed | 2016-11-16 22:00:21 +0900 | [diff] [blame] | 1197 | * @prop_out_fence_ptr: Sync File fd pointer representing the |
| 1198 | * outgoing fences for a CRTC. Userspace should provide a pointer to a |
Gustavo Padovan | d6eefcb | 2017-01-13 12:22:09 -0200 | [diff] [blame] | 1199 | * value of type s32, and then cast that pointer to u64. |
Gustavo Padovan | 710c1ed | 2016-11-16 22:00:21 +0900 | [diff] [blame] | 1200 | */ |
| 1201 | struct drm_property *prop_out_fence_ptr; |
| 1202 | /** |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1203 | * @prop_crtc_id: Default atomic plane property to specify the |
| 1204 | * &drm_crtc. |
| 1205 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1206 | struct drm_property *prop_crtc_id; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1207 | /** |
| 1208 | * @prop_active: Default atomic CRTC property to control the active |
| 1209 | * state, which is the simplified implementation for DPMS in atomic |
| 1210 | * drivers. |
| 1211 | */ |
Daniel Vetter | eab3bbe | 2015-01-22 16:36:21 +0100 | [diff] [blame] | 1212 | struct drm_property *prop_active; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1213 | /** |
| 1214 | * @prop_mode_id: Default atomic CRTC property to set the mode for a |
| 1215 | * CRTC. A 0 mode implies that the CRTC is entirely disabled - all |
| 1216 | * connectors must be of and active must be set to disabled, too. |
| 1217 | */ |
Daniel Stone | 955f3c3 | 2015-05-25 19:11:52 +0100 | [diff] [blame] | 1218 | struct drm_property *prop_mode_id; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1219 | |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1220 | /** |
| 1221 | * @dvi_i_subconnector_property: Optional DVI-I property to |
| 1222 | * differentiate between analog or digital mode. |
| 1223 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1224 | struct drm_property *dvi_i_subconnector_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1225 | /** |
| 1226 | * @dvi_i_select_subconnector_property: Optional DVI-I property to |
| 1227 | * select between analog or digital mode. |
| 1228 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1229 | struct drm_property *dvi_i_select_subconnector_property; |
| 1230 | |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1231 | /** |
| 1232 | * @tv_subconnector_property: Optional TV property to differentiate |
| 1233 | * between different TV connector types. |
| 1234 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1235 | struct drm_property *tv_subconnector_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1236 | /** |
| 1237 | * @tv_select_subconnector_property: Optional TV property to select |
| 1238 | * between different TV connector types. |
| 1239 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1240 | struct drm_property *tv_select_subconnector_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1241 | /** |
| 1242 | * @tv_mode_property: Optional TV property to select |
| 1243 | * the output TV mode. |
| 1244 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1245 | struct drm_property *tv_mode_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1246 | /** |
| 1247 | * @tv_left_margin_property: Optional TV property to set the left |
| 1248 | * margin. |
| 1249 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1250 | struct drm_property *tv_left_margin_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1251 | /** |
| 1252 | * @tv_right_margin_property: Optional TV property to set the right |
| 1253 | * margin. |
| 1254 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1255 | struct drm_property *tv_right_margin_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1256 | /** |
| 1257 | * @tv_top_margin_property: Optional TV property to set the right |
| 1258 | * margin. |
| 1259 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1260 | struct drm_property *tv_top_margin_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1261 | /** |
| 1262 | * @tv_bottom_margin_property: Optional TV property to set the right |
| 1263 | * margin. |
| 1264 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1265 | struct drm_property *tv_bottom_margin_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1266 | /** |
| 1267 | * @tv_brightness_property: Optional TV property to set the |
| 1268 | * brightness. |
| 1269 | */ |
Francisco Jerez | b6b7902 | 2009-08-02 04:19:20 +0200 | [diff] [blame] | 1270 | struct drm_property *tv_brightness_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1271 | /** |
| 1272 | * @tv_contrast_property: Optional TV property to set the |
| 1273 | * contrast. |
| 1274 | */ |
Francisco Jerez | b6b7902 | 2009-08-02 04:19:20 +0200 | [diff] [blame] | 1275 | struct drm_property *tv_contrast_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1276 | /** |
| 1277 | * @tv_flicker_reduction_property: Optional TV property to control the |
| 1278 | * flicker reduction mode. |
| 1279 | */ |
Francisco Jerez | b6b7902 | 2009-08-02 04:19:20 +0200 | [diff] [blame] | 1280 | struct drm_property *tv_flicker_reduction_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1281 | /** |
| 1282 | * @tv_overscan_property: Optional TV property to control the overscan |
| 1283 | * setting. |
| 1284 | */ |
Francisco Jerez | a75f023 | 2009-08-12 02:30:10 +0200 | [diff] [blame] | 1285 | struct drm_property *tv_overscan_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1286 | /** |
| 1287 | * @tv_saturation_property: Optional TV property to set the |
| 1288 | * saturation. |
| 1289 | */ |
Francisco Jerez | a75f023 | 2009-08-12 02:30:10 +0200 | [diff] [blame] | 1290 | struct drm_property *tv_saturation_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1291 | /** |
| 1292 | * @tv_hue_property: Optional TV property to set the hue. |
| 1293 | */ |
Francisco Jerez | a75f023 | 2009-08-12 02:30:10 +0200 | [diff] [blame] | 1294 | struct drm_property *tv_hue_property; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1295 | |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1296 | /** |
| 1297 | * @scaling_mode_property: Optional connector property to control the |
| 1298 | * upscaling, mostly used for built-in panels. |
| 1299 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1300 | struct drm_property *scaling_mode_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1301 | /** |
| 1302 | * @aspect_ratio_property: Optional connector property to control the |
| 1303 | * HDMI infoframe aspect ratio setting. |
| 1304 | */ |
Vandana Kannan | ff587e4 | 2014-06-11 10:46:48 +0530 | [diff] [blame] | 1305 | struct drm_property *aspect_ratio_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1306 | /** |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1307 | * @degamma_lut_property: Optional CRTC property to set the LUT used to |
| 1308 | * convert the framebuffer's colors to linear gamma. |
| 1309 | */ |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 1310 | struct drm_property *degamma_lut_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1311 | /** |
| 1312 | * @degamma_lut_size_property: Optional CRTC property for the size of |
| 1313 | * the degamma LUT as supported by the driver (read-only). |
| 1314 | */ |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 1315 | struct drm_property *degamma_lut_size_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1316 | /** |
| 1317 | * @ctm_property: Optional CRTC property to set the |
| 1318 | * matrix used to convert colors after the lookup in the |
| 1319 | * degamma LUT. |
| 1320 | */ |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 1321 | struct drm_property *ctm_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1322 | /** |
| 1323 | * @gamma_lut_property: Optional CRTC property to set the LUT used to |
| 1324 | * convert the colors, after the CTM matrix, to the gamma space of the |
| 1325 | * connected screen. |
| 1326 | */ |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 1327 | struct drm_property *gamma_lut_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1328 | /** |
| 1329 | * @gamma_lut_size_property: Optional CRTC property for the size of the |
| 1330 | * gamma LUT as supported by the driver (read-only). |
| 1331 | */ |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 1332 | struct drm_property *gamma_lut_size_property; |
| 1333 | |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1334 | /** |
| 1335 | * @suggested_x_property: Optional connector property with a hint for |
| 1336 | * the position of the output on the host's screen. |
| 1337 | */ |
Dave Airlie | 5bb2bbf | 2014-11-10 10:18:15 +1000 | [diff] [blame] | 1338 | struct drm_property *suggested_x_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1339 | /** |
| 1340 | * @suggested_y_property: Optional connector property with a hint for |
| 1341 | * the position of the output on the host's screen. |
| 1342 | */ |
Dave Airlie | 5bb2bbf | 2014-11-10 10:18:15 +1000 | [diff] [blame] | 1343 | struct drm_property *suggested_y_property; |
| 1344 | |
Dave Airlie | 019d96c | 2011-09-29 16:20:42 +0100 | [diff] [blame] | 1345 | /* dumb ioctl parameters */ |
| 1346 | uint32_t preferred_depth, prefer_shadow; |
Keith Packard | 62f2104 | 2013-07-22 18:50:00 -0700 | [diff] [blame] | 1347 | |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1348 | /** |
| 1349 | * @async_page_flip: Does this device support async flips on the primary |
| 1350 | * plane? |
| 1351 | */ |
Keith Packard | 62f2104 | 2013-07-22 18:50:00 -0700 | [diff] [blame] | 1352 | bool async_page_flip; |
Alex Deucher | 8716ed4 | 2014-02-12 12:48:23 -0500 | [diff] [blame] | 1353 | |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 1354 | /** |
| 1355 | * @allow_fb_modifiers: |
| 1356 | * |
| 1357 | * Whether the driver supports fb modifiers in the ADDFB2.1 ioctl call. |
| 1358 | */ |
Rob Clark | e3eb325 | 2015-02-05 14:41:52 +0000 | [diff] [blame] | 1359 | bool allow_fb_modifiers; |
| 1360 | |
Alex Deucher | 8716ed4 | 2014-02-12 12:48:23 -0500 | [diff] [blame] | 1361 | /* cursor size */ |
| 1362 | uint32_t cursor_width, cursor_height; |
Daniel Vetter | 9f2a795 | 2016-06-08 14:19:02 +0200 | [diff] [blame] | 1363 | |
| 1364 | struct drm_mode_config_helper_funcs *helper_private; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1365 | }; |
| 1366 | |
| 1367 | #define obj_to_crtc(x) container_of(x, struct drm_crtc, base) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1368 | |
Ville Syrjälä | f988287 | 2015-12-09 16:19:31 +0200 | [diff] [blame] | 1369 | extern __printf(6, 7) |
| 1370 | int drm_crtc_init_with_planes(struct drm_device *dev, |
| 1371 | struct drm_crtc *crtc, |
| 1372 | struct drm_plane *primary, |
| 1373 | struct drm_plane *cursor, |
| 1374 | const struct drm_crtc_funcs *funcs, |
| 1375 | const char *name, ...); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1376 | extern void drm_crtc_cleanup(struct drm_crtc *crtc); |
Chris Wilson | 490d3d1 | 2016-05-27 20:05:00 +0100 | [diff] [blame] | 1377 | |
| 1378 | /** |
| 1379 | * drm_crtc_index - find the index of a registered CRTC |
| 1380 | * @crtc: CRTC to find index for |
| 1381 | * |
| 1382 | * Given a registered CRTC, return the index of that CRTC within a DRM |
| 1383 | * device's list of CRTCs. |
| 1384 | */ |
Jani Nikula | a5bd451 | 2016-10-10 18:26:10 +0300 | [diff] [blame] | 1385 | static inline unsigned int drm_crtc_index(const struct drm_crtc *crtc) |
Chris Wilson | 490d3d1 | 2016-05-27 20:05:00 +0100 | [diff] [blame] | 1386 | { |
| 1387 | return crtc->index; |
| 1388 | } |
Russell King | db5f7a6 | 2014-01-02 21:27:33 +0000 | [diff] [blame] | 1389 | |
| 1390 | /** |
| 1391 | * drm_crtc_mask - find the mask of a registered CRTC |
| 1392 | * @crtc: CRTC to find mask for |
| 1393 | * |
| 1394 | * Given a registered CRTC, return the mask bit of that CRTC for an |
| 1395 | * encoder's possible_crtcs field. |
| 1396 | */ |
| 1397 | static inline uint32_t drm_crtc_mask(struct drm_crtc *crtc) |
| 1398 | { |
| 1399 | return 1 << drm_crtc_index(crtc); |
| 1400 | } |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1401 | |
Gustavo Padovan | ecb7e16 | 2014-12-01 15:40:09 -0800 | [diff] [blame] | 1402 | extern void drm_crtc_get_hv_timing(const struct drm_display_mode *mode, |
| 1403 | int *hdisplay, int *vdisplay); |
Lukas Wunner | 6a0d952 | 2016-06-08 18:47:27 +0200 | [diff] [blame] | 1404 | extern int drm_crtc_force_disable(struct drm_crtc *crtc); |
| 1405 | extern int drm_crtc_force_disable_all(struct drm_device *dev); |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1406 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1407 | extern void drm_mode_config_init(struct drm_device *dev); |
Chris Wilson | eb03355 | 2011-01-24 15:11:08 +0000 | [diff] [blame] | 1408 | extern void drm_mode_config_reset(struct drm_device *dev); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1409 | extern void drm_mode_config_cleanup(struct drm_device *dev); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1410 | |
Daniel Vetter | 2d13b67 | 2012-12-11 13:47:23 +0100 | [diff] [blame] | 1411 | extern int drm_mode_set_config_internal(struct drm_mode_set *set); |
Daniel Vetter | 8106554 | 2016-06-21 10:54:13 +0200 | [diff] [blame] | 1412 | |
Dave Airlie | 138f9eb | 2014-10-20 16:17:17 +1000 | [diff] [blame] | 1413 | extern struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev, |
| 1414 | char topology[8]); |
| 1415 | extern struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev, |
| 1416 | char topology[8]); |
| 1417 | extern void drm_mode_put_tile_group(struct drm_device *dev, |
| 1418 | struct drm_tile_group *tg); |
Dave Airlie | ff72145b | 2011-02-07 12:16:14 +1000 | [diff] [blame] | 1419 | |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 1420 | /* Helpers */ |
| 1421 | static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev, |
| 1422 | uint32_t id) |
| 1423 | { |
| 1424 | struct drm_mode_object *mo; |
| 1425 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CRTC); |
| 1426 | return mo ? obj_to_crtc(mo) : NULL; |
| 1427 | } |
| 1428 | |
Daniel Vetter | 6295d60 | 2015-07-09 23:44:25 +0200 | [diff] [blame] | 1429 | #define drm_for_each_crtc(crtc, dev) \ |
| 1430 | list_for_each_entry(crtc, &(dev)->mode_config.crtc_list, head) |
| 1431 | |
Daniel Vetter | 7a3f3d6 | 2015-07-09 23:44:28 +0200 | [diff] [blame] | 1432 | static inline void |
| 1433 | assert_drm_connector_list_read_locked(struct drm_mode_config *mode_config) |
| 1434 | { |
Daniel Vetter | cff20ba | 2015-07-09 23:44:33 +0200 | [diff] [blame] | 1435 | /* |
| 1436 | * The connector hotadd/remove code currently grabs both locks when |
| 1437 | * updating lists. Hence readers need only hold either of them to be |
| 1438 | * safe and the check amounts to |
| 1439 | * |
| 1440 | * WARN_ON(not_holding(A) && not_holding(B)). |
| 1441 | */ |
| 1442 | WARN_ON(!mutex_is_locked(&mode_config->mutex) && |
| 1443 | !drm_modeset_is_locked(&mode_config->connection_mutex)); |
Daniel Vetter | 7a3f3d6 | 2015-07-09 23:44:28 +0200 | [diff] [blame] | 1444 | } |
| 1445 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1446 | #endif /* __DRM_CRTC_H__ */ |