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 | 7520a27 | 2016-08-15 16:07:02 +0200 | [diff] [blame] | 39 | #include <drm/drm_modeset.h> |
| 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> |
Jesse Barnes | 308e5bc | 2011-11-14 14:51:28 -0800 | [diff] [blame] | 44 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 45 | struct drm_device; |
| 46 | struct drm_mode_set; |
Thierry Reding | 595887e | 2012-11-21 15:00:47 +0100 | [diff] [blame] | 47 | struct drm_file; |
| 48 | struct drm_clip_rect; |
Russell King | 7e435aa | 2014-06-15 11:07:12 +0100 | [diff] [blame] | 49 | struct device_node; |
Daniel Vetter | e2330f0 | 2014-10-29 11:34:56 +0100 | [diff] [blame] | 50 | struct fence; |
Daniel Vetter | 8106554 | 2016-06-21 10:54:13 +0200 | [diff] [blame] | 51 | struct edid; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 52 | |
Rob Clark | ebc44cf | 2012-09-12 22:22:31 -0500 | [diff] [blame] | 53 | static inline int64_t U642I64(uint64_t val) |
| 54 | { |
| 55 | return (int64_t)*((int64_t *)&val); |
| 56 | } |
| 57 | static inline uint64_t I642U64(int64_t val) |
| 58 | { |
| 59 | return (uint64_t)*((uint64_t *)&val); |
| 60 | } |
| 61 | |
Robert Fekete | d9c3824 | 2015-11-02 16:14:08 +0100 | [diff] [blame] | 62 | /* |
| 63 | * Rotation property bits. DRM_ROTATE_<degrees> rotates the image by the |
| 64 | * specified amount in degrees in counter clockwise direction. DRM_REFLECT_X and |
| 65 | * DRM_REFLECT_Y reflects the image along the specified axis prior to rotation |
| 66 | */ |
Joonas Lahtinen | 31ad61e | 2016-07-29 08:50:05 +0300 | [diff] [blame] | 67 | #define DRM_ROTATE_0 BIT(0) |
| 68 | #define DRM_ROTATE_90 BIT(1) |
| 69 | #define DRM_ROTATE_180 BIT(2) |
| 70 | #define DRM_ROTATE_270 BIT(3) |
| 71 | #define DRM_ROTATE_MASK (DRM_ROTATE_0 | DRM_ROTATE_90 | \ |
| 72 | DRM_ROTATE_180 | DRM_ROTATE_270) |
| 73 | #define DRM_REFLECT_X BIT(4) |
| 74 | #define DRM_REFLECT_Y BIT(5) |
| 75 | #define DRM_REFLECT_MASK (DRM_REFLECT_X | DRM_REFLECT_Y) |
Ville Syrjälä | 0659696 | 2014-07-08 10:31:51 +0530 | [diff] [blame] | 76 | |
Dave Airlie | 138f9eb | 2014-10-20 16:17:17 +1000 | [diff] [blame] | 77 | /* data corresponds to displayid vend/prod/serial */ |
| 78 | struct drm_tile_group { |
| 79 | struct kref refcount; |
| 80 | struct drm_device *dev; |
| 81 | int id; |
| 82 | u8 group_data[8]; |
| 83 | }; |
| 84 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 85 | struct drm_property_blob { |
| 86 | struct drm_mode_object base; |
Daniel Stone | 6bcacf5 | 2015-04-20 19:22:55 +0100 | [diff] [blame] | 87 | struct drm_device *dev; |
Daniel Stone | e2f5d2e | 2015-05-22 13:34:51 +0100 | [diff] [blame] | 88 | struct list_head head_global; |
| 89 | struct list_head head_file; |
Thierry Reding | ecbbe59 | 2014-05-13 11:36:13 +0200 | [diff] [blame] | 90 | size_t length; |
Ville Syrjälä | d63f5e6 | 2012-03-13 12:35:49 +0200 | [diff] [blame] | 91 | unsigned char data[]; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | struct drm_property_enum { |
| 95 | uint64_t value; |
| 96 | struct list_head head; |
| 97 | char name[DRM_PROP_NAME_LEN]; |
| 98 | }; |
| 99 | |
| 100 | struct drm_property { |
| 101 | struct list_head head; |
| 102 | struct drm_mode_object base; |
| 103 | uint32_t flags; |
| 104 | char name[DRM_PROP_NAME_LEN]; |
| 105 | uint32_t num_values; |
| 106 | uint64_t *values; |
Rob Clark | 98f75de | 2014-05-30 11:37:03 -0400 | [diff] [blame] | 107 | struct drm_device *dev; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 108 | |
Daniel Vetter | 3758b34 | 2014-11-19 18:38:10 +0100 | [diff] [blame] | 109 | struct list_head enum_list; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 110 | }; |
| 111 | |
| 112 | struct drm_crtc; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 113 | struct drm_encoder; |
Kristian Høgsberg | d91d8a3 | 2009-11-17 12:43:55 -0500 | [diff] [blame] | 114 | struct drm_pending_vblank_event; |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 115 | struct drm_plane; |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 116 | struct drm_bridge; |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 117 | struct drm_atomic_state; |
| 118 | |
Daniel Vetter | 4490d4c | 2015-12-04 09:45:45 +0100 | [diff] [blame] | 119 | struct drm_crtc_helper_funcs; |
| 120 | struct drm_encoder_helper_funcs; |
Daniel Vetter | 4490d4c | 2015-12-04 09:45:45 +0100 | [diff] [blame] | 121 | struct drm_plane_helper_funcs; |
| 122 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 123 | /** |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 124 | * struct drm_crtc_state - mutable CRTC state |
Daniel Vetter | 07cc0ef | 2014-11-27 15:49:39 +0100 | [diff] [blame] | 125 | * @crtc: backpointer to the CRTC |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 126 | * @enable: whether the CRTC should be enabled, gates all other state |
Daniel Vetter | d9b1362 | 2014-11-26 16:57:41 +0100 | [diff] [blame] | 127 | * @active: whether the CRTC is actively displaying (used for DPMS) |
Maarten Lankhorst | fc59666 | 2015-07-21 13:28:57 +0200 | [diff] [blame] | 128 | * @planes_changed: planes on this crtc are updated |
| 129 | * @mode_changed: crtc_state->mode or crtc_state->enable has been changed |
| 130 | * @active_changed: crtc_state->active has been toggled. |
| 131 | * @connectors_changed: connectors to this crtc have been updated |
Marek Szyprowski | 44d1240d | 2016-06-13 11:11:26 +0200 | [diff] [blame] | 132 | * @zpos_changed: zpos values of planes on this crtc have been updated |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 133 | * @color_mgmt_changed: color management properties have changed (degamma or |
| 134 | * gamma LUT or CSC matrix) |
Rob Clark | 6ddd388 | 2014-11-21 15:28:31 -0500 | [diff] [blame] | 135 | * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes |
Maarten Lankhorst | 4cd9fa5 | 2016-01-04 12:53:18 +0100 | [diff] [blame] | 136 | * @connector_mask: bitmask of (1 << drm_connector_index(connector)) of attached connectors |
Maarten Lankhorst | e87a52b | 2016-01-28 15:04:58 +0100 | [diff] [blame] | 137 | * @encoder_mask: bitmask of (1 << drm_encoder_index(encoder)) of attached encoders |
Daniel Vetter | 623369e | 2014-09-16 17:50:47 +0200 | [diff] [blame] | 138 | * @last_vblank_count: for helpers and drivers to capture the vblank of the |
| 139 | * update to ensure framebuffer cleanup isn't done too early |
Daniel Vetter | 2f324b4 | 2014-10-29 11:13:47 +0100 | [diff] [blame] | 140 | * @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] | 141 | * @mode: current mode timings |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 142 | * @mode_blob: &drm_property_blob for @mode |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 143 | * @degamma_lut: Lookup table for converting framebuffer pixel data |
| 144 | * before apply the conversion matrix |
| 145 | * @ctm: Transformation matrix |
| 146 | * @gamma_lut: Lookup table for converting pixel data after the |
| 147 | * conversion matrix |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 148 | * @event: optional pointer to a DRM event to signal upon completion of the |
| 149 | * state update |
| 150 | * @state: backpointer to global drm_atomic_state |
Daniel Vetter | d9b1362 | 2014-11-26 16:57:41 +0100 | [diff] [blame] | 151 | * |
| 152 | * Note that the distinction between @enable and @active is rather subtile: |
| 153 | * Flipping @active while @enable is set without changing anything else may |
| 154 | * never return in a failure from the ->atomic_check callback. Userspace assumes |
| 155 | * that a DPMS On will always succeed. In other words: @enable controls resource |
| 156 | * assignment, @active controls the actual hardware state. |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 157 | */ |
| 158 | struct drm_crtc_state { |
Daniel Vetter | 07cc0ef | 2014-11-27 15:49:39 +0100 | [diff] [blame] | 159 | struct drm_crtc *crtc; |
| 160 | |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 161 | bool enable; |
Daniel Vetter | d9b1362 | 2014-11-26 16:57:41 +0100 | [diff] [blame] | 162 | bool active; |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 163 | |
Daniel Vetter | c2fcd27 | 2014-11-05 00:14:14 +0100 | [diff] [blame] | 164 | /* computed state bits used by helpers and drivers */ |
| 165 | bool planes_changed : 1; |
Daniel Vetter | 623369e | 2014-09-16 17:50:47 +0200 | [diff] [blame] | 166 | bool mode_changed : 1; |
Daniel Vetter | eab3bbe | 2015-01-22 16:36:21 +0100 | [diff] [blame] | 167 | bool active_changed : 1; |
Maarten Lankhorst | fc59666 | 2015-07-21 13:28:57 +0200 | [diff] [blame] | 168 | bool connectors_changed : 1; |
Marek Szyprowski | 44d1240d | 2016-06-13 11:11:26 +0200 | [diff] [blame] | 169 | bool zpos_changed : 1; |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 170 | bool color_mgmt_changed : 1; |
Daniel Vetter | 623369e | 2014-09-16 17:50:47 +0200 | [diff] [blame] | 171 | |
Rob Clark | 6ddd388 | 2014-11-21 15:28:31 -0500 | [diff] [blame] | 172 | /* attached planes bitmask: |
| 173 | * WARNING: transitional helpers do not maintain plane_mask so |
| 174 | * drivers not converted over to atomic helpers should not rely |
| 175 | * on plane_mask being accurate! |
| 176 | */ |
| 177 | u32 plane_mask; |
| 178 | |
Maarten Lankhorst | 4cd9fa5 | 2016-01-04 12:53:18 +0100 | [diff] [blame] | 179 | u32 connector_mask; |
Maarten Lankhorst | e87a52b | 2016-01-28 15:04:58 +0100 | [diff] [blame] | 180 | u32 encoder_mask; |
Maarten Lankhorst | 4cd9fa5 | 2016-01-04 12:53:18 +0100 | [diff] [blame] | 181 | |
Daniel Vetter | 623369e | 2014-09-16 17:50:47 +0200 | [diff] [blame] | 182 | /* last_vblank_count: for vblank waits before cleanup */ |
| 183 | u32 last_vblank_count; |
Daniel Vetter | c2fcd27 | 2014-11-05 00:14:14 +0100 | [diff] [blame] | 184 | |
Daniel Vetter | 2f324b4 | 2014-10-29 11:13:47 +0100 | [diff] [blame] | 185 | /* adjusted_mode: for use by helpers and drivers */ |
| 186 | struct drm_display_mode adjusted_mode; |
| 187 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 188 | struct drm_display_mode mode; |
| 189 | |
Daniel Stone | 99cf4a2 | 2015-05-25 19:11:51 +0100 | [diff] [blame] | 190 | /* blob property to expose current mode to atomic userspace */ |
| 191 | struct drm_property_blob *mode_blob; |
| 192 | |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 193 | /* blob property to expose color management to userspace */ |
| 194 | struct drm_property_blob *degamma_lut; |
| 195 | struct drm_property_blob *ctm; |
| 196 | struct drm_property_blob *gamma_lut; |
| 197 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 198 | struct drm_pending_vblank_event *event; |
| 199 | |
| 200 | struct drm_atomic_state *state; |
| 201 | }; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 202 | |
| 203 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 204 | * struct drm_crtc_funcs - control CRTCs for a given device |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 205 | * |
| 206 | * The drm_crtc_funcs structure is the central CRTC management structure |
| 207 | * in the DRM. Each CRTC controls one or more connectors (note that the name |
| 208 | * CRTC is simply historical, a CRTC may control LVDS, VGA, DVI, TV out, etc. |
| 209 | * connectors, not just CRTs). |
| 210 | * |
| 211 | * Each driver is responsible for filling out this structure at startup time, |
| 212 | * in addition to providing other modesetting features, like i2c and DDC |
| 213 | * bus accessors. |
| 214 | */ |
| 215 | struct drm_crtc_funcs { |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 216 | /** |
| 217 | * @reset: |
| 218 | * |
| 219 | * Reset CRTC hardware and software state to off. This function isn't |
| 220 | * called by the core directly, only through drm_mode_config_reset(). |
| 221 | * It's not a helper hook only for historical reasons. |
| 222 | * |
| 223 | * Atomic drivers can use drm_atomic_helper_crtc_reset() to reset |
| 224 | * atomic state using this hook. |
| 225 | */ |
Chris Wilson | eb03355 | 2011-01-24 15:11:08 +0000 | [diff] [blame] | 226 | void (*reset)(struct drm_crtc *crtc); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 227 | |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 228 | /** |
| 229 | * @cursor_set: |
| 230 | * |
| 231 | * Update the cursor image. The cursor position is relative to the CRTC |
| 232 | * and can be partially or fully outside of the visible area. |
| 233 | * |
| 234 | * Note that contrary to all other KMS functions the legacy cursor entry |
| 235 | * points don't take a framebuffer object, but instead take directly a |
| 236 | * raw buffer object id from the driver's buffer manager (which is |
| 237 | * either GEM or TTM for current drivers). |
| 238 | * |
| 239 | * This entry point is deprecated, drivers should instead implement |
| 240 | * universal plane support and register a proper cursor plane using |
| 241 | * drm_crtc_init_with_planes(). |
| 242 | * |
| 243 | * This callback is optional |
| 244 | * |
| 245 | * RETURNS: |
| 246 | * |
| 247 | * 0 on success or a negative error code on failure. |
| 248 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 249 | int (*cursor_set)(struct drm_crtc *crtc, struct drm_file *file_priv, |
| 250 | uint32_t handle, uint32_t width, uint32_t height); |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 251 | |
| 252 | /** |
| 253 | * @cursor_set2: |
| 254 | * |
| 255 | * Update the cursor image, including hotspot information. The hotspot |
| 256 | * must not affect the cursor position in CRTC coordinates, but is only |
| 257 | * meant as a hint for virtualized display hardware to coordinate the |
| 258 | * guests and hosts cursor position. The cursor hotspot is relative to |
| 259 | * the cursor image. Otherwise this works exactly like @cursor_set. |
| 260 | * |
| 261 | * This entry point is deprecated, drivers should instead implement |
| 262 | * universal plane support and register a proper cursor plane using |
| 263 | * drm_crtc_init_with_planes(). |
| 264 | * |
| 265 | * This callback is optional. |
| 266 | * |
| 267 | * RETURNS: |
| 268 | * |
| 269 | * 0 on success or a negative error code on failure. |
| 270 | */ |
Dave Airlie | 4c813d4 | 2013-06-20 11:48:52 +1000 | [diff] [blame] | 271 | int (*cursor_set2)(struct drm_crtc *crtc, struct drm_file *file_priv, |
| 272 | uint32_t handle, uint32_t width, uint32_t height, |
| 273 | int32_t hot_x, int32_t hot_y); |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 274 | |
| 275 | /** |
| 276 | * @cursor_move: |
| 277 | * |
| 278 | * Update the cursor position. The cursor does not need to be visible |
| 279 | * when this hook is called. |
| 280 | * |
| 281 | * This entry point is deprecated, drivers should instead implement |
| 282 | * universal plane support and register a proper cursor plane using |
| 283 | * drm_crtc_init_with_planes(). |
| 284 | * |
| 285 | * This callback is optional. |
| 286 | * |
| 287 | * RETURNS: |
| 288 | * |
| 289 | * 0 on success or a negative error code on failure. |
| 290 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 291 | int (*cursor_move)(struct drm_crtc *crtc, int x, int y); |
| 292 | |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 293 | /** |
| 294 | * @gamma_set: |
| 295 | * |
| 296 | * Set gamma on the CRTC. |
| 297 | * |
| 298 | * This callback is optional. |
| 299 | * |
| 300 | * NOTE: |
| 301 | * |
| 302 | * Drivers that support gamma tables and also fbdev emulation through |
| 303 | * the provided helper library need to take care to fill out the gamma |
| 304 | * hooks for both. Currently there's a bit an unfortunate duplication |
| 305 | * going on, which should eventually be unified to just one set of |
| 306 | * hooks. |
| 307 | */ |
Maarten Lankhorst | 7ea7728 | 2016-06-07 12:49:30 +0200 | [diff] [blame] | 308 | int (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, |
| 309 | uint32_t size); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 310 | |
| 311 | /** |
| 312 | * @destroy: |
| 313 | * |
| 314 | * Clean up plane resources. This is only called at driver unload time |
| 315 | * through drm_mode_config_cleanup() since a CRTC cannot be hotplugged |
| 316 | * in DRM. |
| 317 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 318 | void (*destroy)(struct drm_crtc *crtc); |
| 319 | |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 320 | /** |
| 321 | * @set_config: |
| 322 | * |
| 323 | * This is the main legacy entry point to change the modeset state on a |
| 324 | * CRTC. All the details of the desired configuration are passed in a |
| 325 | * struct &drm_mode_set - see there for details. |
| 326 | * |
| 327 | * Drivers implementing atomic modeset should use |
| 328 | * drm_atomic_helper_set_config() to implement this hook. |
| 329 | * |
| 330 | * RETURNS: |
| 331 | * |
| 332 | * 0 on success or a negative error code on failure. |
| 333 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 334 | int (*set_config)(struct drm_mode_set *set); |
Kristian Høgsberg | d91d8a3 | 2009-11-17 12:43:55 -0500 | [diff] [blame] | 335 | |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 336 | /** |
| 337 | * @page_flip: |
| 338 | * |
| 339 | * Legacy entry point to schedule a flip to the given framebuffer. |
| 340 | * |
| 341 | * Page flipping is a synchronization mechanism that replaces the frame |
| 342 | * buffer being scanned out by the CRTC with a new frame buffer during |
| 343 | * vertical blanking, avoiding tearing (except when requested otherwise |
| 344 | * through the DRM_MODE_PAGE_FLIP_ASYNC flag). When an application |
| 345 | * requests a page flip the DRM core verifies that the new frame buffer |
| 346 | * is large enough to be scanned out by the CRTC in the currently |
| 347 | * configured mode and then calls the CRTC ->page_flip() operation with a |
| 348 | * pointer to the new frame buffer. |
| 349 | * |
| 350 | * The driver must wait for any pending rendering to the new framebuffer |
| 351 | * to complete before executing the flip. It should also wait for any |
| 352 | * pending rendering from other drivers if the underlying buffer is a |
| 353 | * shared dma-buf. |
| 354 | * |
| 355 | * An application can request to be notified when the page flip has |
| 356 | * completed. The drm core will supply a struct &drm_event in the event |
| 357 | * parameter in this case. This can be handled by the |
| 358 | * drm_crtc_send_vblank_event() function, which the driver should call on |
| 359 | * the provided event upon completion of the flip. Note that if |
| 360 | * the driver supports vblank signalling and timestamping the vblank |
| 361 | * counters and timestamps must agree with the ones returned from page |
| 362 | * flip events. With the current vblank helper infrastructure this can |
| 363 | * be achieved by holding a vblank reference while the page flip is |
| 364 | * pending, acquired through drm_crtc_vblank_get() and released with |
| 365 | * drm_crtc_vblank_put(). Drivers are free to implement their own vblank |
| 366 | * counter and timestamp tracking though, e.g. if they have accurate |
| 367 | * timestamp registers in hardware. |
| 368 | * |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 369 | * This callback is optional. |
| 370 | * |
| 371 | * NOTE: |
| 372 | * |
| 373 | * Very early versions of the KMS ABI mandated that the driver must |
| 374 | * block (but not reject) any rendering to the old framebuffer until the |
| 375 | * flip operation has completed and the old framebuffer is no longer |
| 376 | * visible. This requirement has been lifted, and userspace is instead |
| 377 | * expected to request delivery of an event and wait with recycling old |
| 378 | * buffers until such has been received. |
| 379 | * |
| 380 | * RETURNS: |
| 381 | * |
| 382 | * 0 on success or a negative error code on failure. Note that if a |
| 383 | * ->page_flip() operation is already pending the callback should return |
| 384 | * -EBUSY. Pageflips on a disabled CRTC (either by setting a NULL mode |
| 385 | * or just runtime disabled through DPMS respectively the new atomic |
Daniel Vetter | 4cba685 | 2015-12-08 09:49:20 +0100 | [diff] [blame] | 386 | * "ACTIVE" state) should result in an -EINVAL error code. Note that |
| 387 | * drm_atomic_helper_page_flip() checks this already for atomic drivers. |
Kristian Høgsberg | d91d8a3 | 2009-11-17 12:43:55 -0500 | [diff] [blame] | 388 | */ |
| 389 | int (*page_flip)(struct drm_crtc *crtc, |
| 390 | struct drm_framebuffer *fb, |
Keith Packard | ed8d197 | 2013-07-22 18:49:58 -0700 | [diff] [blame] | 391 | struct drm_pending_vblank_event *event, |
| 392 | uint32_t flags); |
Paulo Zanoni | bffd9de0 | 2012-05-15 18:09:05 -0300 | [diff] [blame] | 393 | |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 394 | /** |
| 395 | * @set_property: |
| 396 | * |
| 397 | * This is the legacy entry point to update a property attached to the |
| 398 | * CRTC. |
| 399 | * |
| 400 | * Drivers implementing atomic modeset should use |
| 401 | * drm_atomic_helper_crtc_set_property() to implement this hook. |
| 402 | * |
| 403 | * This callback is optional if the driver does not support any legacy |
| 404 | * driver-private properties. |
| 405 | * |
| 406 | * RETURNS: |
| 407 | * |
| 408 | * 0 on success or a negative error code on failure. |
| 409 | */ |
Paulo Zanoni | bffd9de0 | 2012-05-15 18:09:05 -0300 | [diff] [blame] | 410 | int (*set_property)(struct drm_crtc *crtc, |
| 411 | struct drm_property *property, uint64_t val); |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 412 | |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 413 | /** |
| 414 | * @atomic_duplicate_state: |
| 415 | * |
| 416 | * Duplicate the current atomic state for this CRTC and return it. |
| 417 | * The core and helpers gurantee that any atomic state duplicated with |
| 418 | * this hook and still owned by the caller (i.e. not transferred to the |
| 419 | * driver by calling ->atomic_commit() from struct |
| 420 | * &drm_mode_config_funcs) will be cleaned up by calling the |
| 421 | * @atomic_destroy_state hook in this structure. |
| 422 | * |
| 423 | * Atomic drivers which don't subclass struct &drm_crtc should use |
| 424 | * drm_atomic_helper_crtc_duplicate_state(). Drivers that subclass the |
| 425 | * state structure to extend it with driver-private state should use |
| 426 | * __drm_atomic_helper_crtc_duplicate_state() to make sure shared state is |
| 427 | * duplicated in a consistent fashion across drivers. |
| 428 | * |
| 429 | * It is an error to call this hook before crtc->state has been |
| 430 | * initialized correctly. |
| 431 | * |
| 432 | * NOTE: |
| 433 | * |
| 434 | * If the duplicate state references refcounted resources this hook must |
| 435 | * acquire a reference for each of them. The driver must release these |
| 436 | * references again in @atomic_destroy_state. |
| 437 | * |
| 438 | * RETURNS: |
| 439 | * |
| 440 | * Duplicated atomic state or NULL when the allocation failed. |
| 441 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 442 | struct drm_crtc_state *(*atomic_duplicate_state)(struct drm_crtc *crtc); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 443 | |
| 444 | /** |
| 445 | * @atomic_destroy_state: |
| 446 | * |
| 447 | * Destroy a state duplicated with @atomic_duplicate_state and release |
| 448 | * or unreference all resources it references |
| 449 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 450 | void (*atomic_destroy_state)(struct drm_crtc *crtc, |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 451 | struct drm_crtc_state *state); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 452 | |
| 453 | /** |
| 454 | * @atomic_set_property: |
| 455 | * |
| 456 | * Decode a driver-private property value and store the decoded value |
| 457 | * into the passed-in state structure. Since the atomic core decodes all |
| 458 | * standardized properties (even for extensions beyond the core set of |
| 459 | * properties which might not be implemented by all drivers) this |
| 460 | * requires drivers to subclass the state structure. |
| 461 | * |
| 462 | * Such driver-private properties should really only be implemented for |
| 463 | * truly hardware/vendor specific state. Instead it is preferred to |
| 464 | * standardize atomic extension and decode the properties used to expose |
| 465 | * such an extension in the core. |
| 466 | * |
| 467 | * Do not call this function directly, use |
| 468 | * drm_atomic_crtc_set_property() instead. |
| 469 | * |
| 470 | * This callback is optional if the driver does not support any |
| 471 | * driver-private atomic properties. |
| 472 | * |
| 473 | * NOTE: |
| 474 | * |
| 475 | * This function is called in the state assembly phase of atomic |
| 476 | * modesets, which can be aborted for any reason (including on |
| 477 | * userspace's request to just check whether a configuration would be |
| 478 | * possible). Drivers MUST NOT touch any persistent state (hardware or |
| 479 | * software) or data structures except the passed in @state parameter. |
| 480 | * |
| 481 | * Also since userspace controls in which order properties are set this |
| 482 | * function must not do any input validation (since the state update is |
| 483 | * incomplete and hence likely inconsistent). Instead any such input |
| 484 | * validation must be done in the various atomic_check callbacks. |
| 485 | * |
| 486 | * RETURNS: |
| 487 | * |
| 488 | * 0 if the property has been found, -EINVAL if the property isn't |
| 489 | * implemented by the driver (which should never happen, the core only |
| 490 | * asks for properties attached to this CRTC). No other validation is |
| 491 | * allowed by the driver. The core already checks that the property |
| 492 | * value is within the range (integer, valid enum value, ...) the driver |
| 493 | * set when registering the property. |
| 494 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 495 | int (*atomic_set_property)(struct drm_crtc *crtc, |
| 496 | struct drm_crtc_state *state, |
| 497 | struct drm_property *property, |
| 498 | uint64_t val); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 499 | /** |
| 500 | * @atomic_get_property: |
| 501 | * |
| 502 | * Reads out the decoded driver-private property. This is used to |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 503 | * implement the GETCRTC IOCTL. |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 504 | * |
| 505 | * Do not call this function directly, use |
| 506 | * drm_atomic_crtc_get_property() instead. |
| 507 | * |
| 508 | * This callback is optional if the driver does not support any |
| 509 | * driver-private atomic properties. |
| 510 | * |
| 511 | * RETURNS: |
| 512 | * |
| 513 | * 0 on success, -EINVAL if the property isn't implemented by the |
| 514 | * driver (which should never happen, the core only asks for |
| 515 | * properties attached to this CRTC). |
| 516 | */ |
Rob Clark | ac9c925 | 2014-12-18 16:01:47 -0500 | [diff] [blame] | 517 | int (*atomic_get_property)(struct drm_crtc *crtc, |
| 518 | const struct drm_crtc_state *state, |
| 519 | struct drm_property *property, |
| 520 | uint64_t *val); |
Benjamin Gaignard | 79190ea | 2016-06-21 16:37:09 +0200 | [diff] [blame] | 521 | |
| 522 | /** |
| 523 | * @late_register: |
| 524 | * |
| 525 | * This optional hook can be used to register additional userspace |
| 526 | * interfaces attached to the crtc like debugfs interfaces. |
| 527 | * It is called late in the driver load sequence from drm_dev_register(). |
| 528 | * Everything added from this callback should be unregistered in |
| 529 | * the early_unregister callback. |
| 530 | * |
| 531 | * Returns: |
| 532 | * |
| 533 | * 0 on success, or a negative error code on failure. |
| 534 | */ |
| 535 | int (*late_register)(struct drm_crtc *crtc); |
| 536 | |
| 537 | /** |
| 538 | * @early_unregister: |
| 539 | * |
| 540 | * This optional hook should be used to unregister the additional |
| 541 | * userspace interfaces attached to the crtc from |
| 542 | * late_unregister(). It is called from drm_dev_unregister(), |
| 543 | * early in the driver unload sequence to disable userspace access |
| 544 | * before data structures are torndown. |
| 545 | */ |
| 546 | void (*early_unregister)(struct drm_crtc *crtc); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 547 | }; |
| 548 | |
| 549 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 550 | * struct drm_crtc - central CRTC control structure |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 551 | * @dev: parent DRM device |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 552 | * @port: OF node used by drm_of_find_possible_crtcs() |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 553 | * @head: list management |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 554 | * @name: human readable name, can be overwritten by the driver |
Rob Clark | 51fd371 | 2013-11-19 12:10:12 -0500 | [diff] [blame] | 555 | * @mutex: per-CRTC locking |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 556 | * @base: base KMS object for ID tracking etc. |
Matt Roper | e13161a | 2014-04-01 15:22:38 -0700 | [diff] [blame] | 557 | * @primary: primary plane for this CRTC |
| 558 | * @cursor: cursor plane for this CRTC |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 559 | * @cursor_x: current x position of the cursor, used for universal cursor planes |
| 560 | * @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] | 561 | * @enabled: is this CRTC enabled? |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 562 | * @mode: current mode timings |
| 563 | * @hwmode: mode timings as programmed to hw regs |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 564 | * @x: x position on screen |
| 565 | * @y: y position on screen |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 566 | * @funcs: CRTC control functions |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 567 | * @gamma_size: size of gamma ramp |
| 568 | * @gamma_store: gamma ramp values |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 569 | * @helper_private: mid-layer private data |
Paulo Zanoni | bffd9de0 | 2012-05-15 18:09:05 -0300 | [diff] [blame] | 570 | * @properties: property tracking for this CRTC |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 571 | * |
| 572 | * Each CRTC may have one or more connectors associated with it. This structure |
| 573 | * allows the CRTC to be controlled. |
| 574 | */ |
| 575 | struct drm_crtc { |
| 576 | struct drm_device *dev; |
Russell King | 7e435aa | 2014-06-15 11:07:12 +0100 | [diff] [blame] | 577 | struct device_node *port; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 578 | struct list_head head; |
| 579 | |
Ville Syrjälä | fa3ab4c | 2015-12-08 18:41:53 +0200 | [diff] [blame] | 580 | char *name; |
| 581 | |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 582 | /** |
| 583 | * @mutex: |
Daniel Vetter | 29494c1 | 2012-12-02 02:18:25 +0100 | [diff] [blame] | 584 | * |
| 585 | * This provides a read lock for the overall crtc state (mode, dpms |
| 586 | * state, ...) and a write lock for everything which can be update |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 587 | * without a full modeset (fb, cursor data, crtc properties ...). Full |
| 588 | * modeset also need to grab dev->mode_config.connection_mutex. |
Daniel Vetter | 29494c1 | 2012-12-02 02:18:25 +0100 | [diff] [blame] | 589 | */ |
Rob Clark | 51fd371 | 2013-11-19 12:10:12 -0500 | [diff] [blame] | 590 | struct drm_modeset_lock mutex; |
Daniel Vetter | 29494c1 | 2012-12-02 02:18:25 +0100 | [diff] [blame] | 591 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 592 | struct drm_mode_object base; |
| 593 | |
Matt Roper | e13161a | 2014-04-01 15:22:38 -0700 | [diff] [blame] | 594 | /* primary and cursor planes for CRTC */ |
| 595 | struct drm_plane *primary; |
| 596 | struct drm_plane *cursor; |
| 597 | |
Daniel Vetter | 9609408 | 2016-07-15 21:47:59 +0200 | [diff] [blame] | 598 | /** |
| 599 | * @index: Position inside the mode_config.list, can be used as an array |
| 600 | * index. It is invariant over the lifetime of the CRTC. |
| 601 | */ |
Chris Wilson | 490d3d1 | 2016-05-27 20:05:00 +0100 | [diff] [blame] | 602 | unsigned index; |
| 603 | |
Matt Roper | 161d0dc | 2014-06-10 08:28:10 -0700 | [diff] [blame] | 604 | /* position of cursor plane on crtc */ |
| 605 | int cursor_x; |
| 606 | int cursor_y; |
| 607 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 608 | bool enabled; |
| 609 | |
Mario Kleiner | 27641c3 | 2010-10-23 04:20:23 +0200 | [diff] [blame] | 610 | /* Requested mode from modesetting. */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 611 | struct drm_display_mode mode; |
| 612 | |
Mario Kleiner | 27641c3 | 2010-10-23 04:20:23 +0200 | [diff] [blame] | 613 | /* Programmed mode in hw, after adjustments for encoders, |
| 614 | * crtc, panel scaling etc. Needed for timestamping etc. |
| 615 | */ |
| 616 | struct drm_display_mode hwmode; |
| 617 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 618 | int x, y; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 619 | const struct drm_crtc_funcs *funcs; |
| 620 | |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 621 | /* Legacy FB CRTC gamma size for reporting to userspace */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 622 | uint32_t gamma_size; |
| 623 | uint16_t *gamma_store; |
| 624 | |
| 625 | /* if you are using the helper */ |
Daniel Vetter | 4490d4c | 2015-12-04 09:45:45 +0100 | [diff] [blame] | 626 | const struct drm_crtc_helper_funcs *helper_private; |
Paulo Zanoni | bffd9de0 | 2012-05-15 18:09:05 -0300 | [diff] [blame] | 627 | |
| 628 | struct drm_object_properties properties; |
Daniel Vetter | d059f65 | 2014-07-25 18:07:40 +0200 | [diff] [blame] | 629 | |
Daniel Vetter | 3b24f7d | 2016-06-08 14:19:00 +0200 | [diff] [blame] | 630 | /** |
| 631 | * @state: |
| 632 | * |
| 633 | * Current atomic state for this CRTC. |
| 634 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 635 | struct drm_crtc_state *state; |
| 636 | |
Daniel Vetter | 3b24f7d | 2016-06-08 14:19:00 +0200 | [diff] [blame] | 637 | /** |
| 638 | * @commit_list: |
| 639 | * |
| 640 | * List of &drm_crtc_commit structures tracking pending commits. |
| 641 | * Protected by @commit_lock. This list doesn't hold its own full |
| 642 | * reference, but burrows it from the ongoing commit. Commit entries |
| 643 | * must be removed from this list once the commit is fully completed, |
| 644 | * but before it's correspoding &drm_atomic_state gets destroyed. |
| 645 | */ |
| 646 | struct list_head commit_list; |
| 647 | |
| 648 | /** |
| 649 | * @commit_lock: |
| 650 | * |
| 651 | * Spinlock to protect @commit_list. |
| 652 | */ |
| 653 | spinlock_t commit_lock; |
| 654 | |
| 655 | /** |
| 656 | * @acquire_ctx: |
| 657 | * |
| 658 | * Per-CRTC implicit acquire context used by atomic drivers for legacy |
| 659 | * IOCTLs, so that atomic drivers can get at the locking acquire |
| 660 | * context. |
Daniel Vetter | d059f65 | 2014-07-25 18:07:40 +0200 | [diff] [blame] | 661 | */ |
| 662 | struct drm_modeset_acquire_ctx *acquire_ctx; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 663 | }; |
| 664 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 665 | /** |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 666 | * struct drm_plane_state - mutable plane state |
Daniel Vetter | 07cc0ef | 2014-11-27 15:49:39 +0100 | [diff] [blame] | 667 | * @plane: backpointer to the plane |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 668 | * @crtc: currently bound CRTC, NULL if disabled |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 669 | * @fb: currently bound framebuffer |
Daniel Vetter | e2330f0 | 2014-10-29 11:34:56 +0100 | [diff] [blame] | 670 | * @fence: optional fence to wait for before scanning out @fb |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 671 | * @crtc_x: left position of visible portion of plane on crtc |
| 672 | * @crtc_y: upper position of visible portion of plane on crtc |
| 673 | * @crtc_w: width of visible portion of plane on crtc |
| 674 | * @crtc_h: height of visible portion of plane on crtc |
| 675 | * @src_x: left position of visible portion of plane within |
| 676 | * plane (in 16.16) |
| 677 | * @src_y: upper position of visible portion of plane within |
| 678 | * plane (in 16.16) |
| 679 | * @src_w: width of visible portion of plane (in 16.16) |
| 680 | * @src_h: height of visible portion of plane (in 16.16) |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 681 | * @rotation: rotation of the plane |
Marek Szyprowski | 44d1240d | 2016-06-13 11:11:26 +0200 | [diff] [blame] | 682 | * @zpos: priority of the given plane on crtc (optional) |
| 683 | * @normalized_zpos: normalized value of zpos: unique, range from 0 to N-1 |
| 684 | * where N is the number of active planes for given crtc |
Ville Syrjälä | d7da824 | 2016-07-26 19:06:57 +0300 | [diff] [blame] | 685 | * @src: clipped source coordinates of the plane (in 16.16) |
| 686 | * @dst: clipped destination coordinates of the plane |
| 687 | * @visible: visibility of the plane |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 688 | * @state: backpointer to global drm_atomic_state |
| 689 | */ |
| 690 | struct drm_plane_state { |
Daniel Vetter | 07cc0ef | 2014-11-27 15:49:39 +0100 | [diff] [blame] | 691 | struct drm_plane *plane; |
| 692 | |
Rob Clark | 6ddd388 | 2014-11-21 15:28:31 -0500 | [diff] [blame] | 693 | struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_plane() */ |
| 694 | struct drm_framebuffer *fb; /* do not write directly, use drm_atomic_set_fb_for_plane() */ |
Daniel Vetter | e2330f0 | 2014-10-29 11:34:56 +0100 | [diff] [blame] | 695 | struct fence *fence; |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 696 | |
| 697 | /* Signed dest location allows it to be partially off screen */ |
| 698 | int32_t crtc_x, crtc_y; |
| 699 | uint32_t crtc_w, crtc_h; |
| 700 | |
| 701 | /* Source values are 16.16 fixed point */ |
| 702 | uint32_t src_x, src_y; |
| 703 | uint32_t src_h, src_w; |
| 704 | |
Matt Roper | 1da3062 | 2015-01-21 16:35:40 -0800 | [diff] [blame] | 705 | /* Plane rotation */ |
| 706 | unsigned int rotation; |
| 707 | |
Marek Szyprowski | 44d1240d | 2016-06-13 11:11:26 +0200 | [diff] [blame] | 708 | /* Plane zpos */ |
| 709 | unsigned int zpos; |
| 710 | unsigned int normalized_zpos; |
| 711 | |
Ville Syrjälä | d7da824 | 2016-07-26 19:06:57 +0300 | [diff] [blame] | 712 | /* Clipped coordinates */ |
| 713 | struct drm_rect src, dst; |
| 714 | |
| 715 | /* |
| 716 | * Is the plane actually visible? Can be false even |
| 717 | * if fb!=NULL and crtc!=NULL, due to clipping. |
| 718 | */ |
| 719 | bool visible; |
| 720 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 721 | struct drm_atomic_state *state; |
| 722 | }; |
| 723 | |
| 724 | |
| 725 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 726 | * struct drm_plane_funcs - driver plane control functions |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 727 | */ |
| 728 | struct drm_plane_funcs { |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 729 | /** |
| 730 | * @update_plane: |
| 731 | * |
| 732 | * This is the legacy entry point to enable and configure the plane for |
| 733 | * the given CRTC and framebuffer. It is never called to disable the |
| 734 | * plane, i.e. the passed-in crtc and fb paramters are never NULL. |
| 735 | * |
| 736 | * The source rectangle in frame buffer memory coordinates is given by |
| 737 | * the src_x, src_y, src_w and src_h parameters (as 16.16 fixed point |
| 738 | * values). Devices that don't support subpixel plane coordinates can |
| 739 | * ignore the fractional part. |
| 740 | * |
| 741 | * The destination rectangle in CRTC coordinates is given by the |
| 742 | * crtc_x, crtc_y, crtc_w and crtc_h parameters (as integer values). |
| 743 | * Devices scale the source rectangle to the destination rectangle. If |
| 744 | * scaling is not supported, and the source rectangle size doesn't match |
| 745 | * the destination rectangle size, the driver must return a |
| 746 | * -<errorname>EINVAL</errorname> error. |
| 747 | * |
| 748 | * Drivers implementing atomic modeset should use |
| 749 | * drm_atomic_helper_update_plane() to implement this hook. |
| 750 | * |
| 751 | * RETURNS: |
| 752 | * |
| 753 | * 0 on success or a negative error code on failure. |
| 754 | */ |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 755 | int (*update_plane)(struct drm_plane *plane, |
| 756 | struct drm_crtc *crtc, struct drm_framebuffer *fb, |
| 757 | int crtc_x, int crtc_y, |
| 758 | unsigned int crtc_w, unsigned int crtc_h, |
| 759 | uint32_t src_x, uint32_t src_y, |
| 760 | uint32_t src_w, uint32_t src_h); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 761 | |
| 762 | /** |
| 763 | * @disable_plane: |
| 764 | * |
| 765 | * This is the legacy entry point to disable the plane. The DRM core |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 766 | * calls this method in response to a DRM_IOCTL_MODE_SETPLANE IOCTL call |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 767 | * with the frame buffer ID set to 0. Disabled planes must not be |
| 768 | * processed by the CRTC. |
| 769 | * |
| 770 | * Drivers implementing atomic modeset should use |
| 771 | * drm_atomic_helper_disable_plane() to implement this hook. |
| 772 | * |
| 773 | * RETURNS: |
| 774 | * |
| 775 | * 0 on success or a negative error code on failure. |
| 776 | */ |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 777 | int (*disable_plane)(struct drm_plane *plane); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 778 | |
| 779 | /** |
| 780 | * @destroy: |
| 781 | * |
| 782 | * Clean up plane resources. This is only called at driver unload time |
| 783 | * through drm_mode_config_cleanup() since a plane cannot be hotplugged |
| 784 | * in DRM. |
| 785 | */ |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 786 | void (*destroy)(struct drm_plane *plane); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 787 | |
| 788 | /** |
| 789 | * @reset: |
| 790 | * |
| 791 | * Reset plane hardware and software state to off. This function isn't |
| 792 | * called by the core directly, only through drm_mode_config_reset(). |
| 793 | * It's not a helper hook only for historical reasons. |
| 794 | * |
| 795 | * Atomic drivers can use drm_atomic_helper_plane_reset() to reset |
| 796 | * atomic state using this hook. |
| 797 | */ |
Daniel Vetter | 2a0d7cf | 2014-07-29 15:32:37 +0200 | [diff] [blame] | 798 | void (*reset)(struct drm_plane *plane); |
Rob Clark | 4d93914 | 2012-05-17 02:23:27 -0600 | [diff] [blame] | 799 | |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 800 | /** |
| 801 | * @set_property: |
| 802 | * |
| 803 | * This is the legacy entry point to update a property attached to the |
| 804 | * plane. |
| 805 | * |
| 806 | * Drivers implementing atomic modeset should use |
| 807 | * drm_atomic_helper_plane_set_property() to implement this hook. |
| 808 | * |
| 809 | * This callback is optional if the driver does not support any legacy |
| 810 | * driver-private properties. |
| 811 | * |
| 812 | * RETURNS: |
| 813 | * |
| 814 | * 0 on success or a negative error code on failure. |
| 815 | */ |
Rob Clark | 4d93914 | 2012-05-17 02:23:27 -0600 | [diff] [blame] | 816 | int (*set_property)(struct drm_plane *plane, |
| 817 | struct drm_property *property, uint64_t val); |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 818 | |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 819 | /** |
| 820 | * @atomic_duplicate_state: |
| 821 | * |
| 822 | * Duplicate the current atomic state for this plane and return it. |
| 823 | * The core and helpers gurantee that any atomic state duplicated with |
| 824 | * this hook and still owned by the caller (i.e. not transferred to the |
| 825 | * driver by calling ->atomic_commit() from struct |
| 826 | * &drm_mode_config_funcs) will be cleaned up by calling the |
| 827 | * @atomic_destroy_state hook in this structure. |
| 828 | * |
| 829 | * Atomic drivers which don't subclass struct &drm_plane_state should use |
| 830 | * drm_atomic_helper_plane_duplicate_state(). Drivers that subclass the |
| 831 | * state structure to extend it with driver-private state should use |
| 832 | * __drm_atomic_helper_plane_duplicate_state() to make sure shared state is |
| 833 | * duplicated in a consistent fashion across drivers. |
| 834 | * |
| 835 | * It is an error to call this hook before plane->state has been |
| 836 | * initialized correctly. |
| 837 | * |
| 838 | * NOTE: |
| 839 | * |
| 840 | * If the duplicate state references refcounted resources this hook must |
| 841 | * acquire a reference for each of them. The driver must release these |
| 842 | * references again in @atomic_destroy_state. |
| 843 | * |
| 844 | * RETURNS: |
| 845 | * |
| 846 | * Duplicated atomic state or NULL when the allocation failed. |
| 847 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 848 | struct drm_plane_state *(*atomic_duplicate_state)(struct drm_plane *plane); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 849 | |
| 850 | /** |
| 851 | * @atomic_destroy_state: |
| 852 | * |
| 853 | * Destroy a state duplicated with @atomic_duplicate_state and release |
| 854 | * or unreference all resources it references |
| 855 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 856 | void (*atomic_destroy_state)(struct drm_plane *plane, |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 857 | struct drm_plane_state *state); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 858 | |
| 859 | /** |
| 860 | * @atomic_set_property: |
| 861 | * |
| 862 | * Decode a driver-private property value and store the decoded value |
| 863 | * into the passed-in state structure. Since the atomic core decodes all |
| 864 | * standardized properties (even for extensions beyond the core set of |
| 865 | * properties which might not be implemented by all drivers) this |
| 866 | * requires drivers to subclass the state structure. |
| 867 | * |
| 868 | * Such driver-private properties should really only be implemented for |
| 869 | * truly hardware/vendor specific state. Instead it is preferred to |
| 870 | * standardize atomic extension and decode the properties used to expose |
| 871 | * such an extension in the core. |
| 872 | * |
| 873 | * Do not call this function directly, use |
| 874 | * drm_atomic_plane_set_property() instead. |
| 875 | * |
| 876 | * This callback is optional if the driver does not support any |
| 877 | * driver-private atomic properties. |
| 878 | * |
| 879 | * NOTE: |
| 880 | * |
| 881 | * This function is called in the state assembly phase of atomic |
| 882 | * modesets, which can be aborted for any reason (including on |
| 883 | * userspace's request to just check whether a configuration would be |
| 884 | * possible). Drivers MUST NOT touch any persistent state (hardware or |
| 885 | * software) or data structures except the passed in @state parameter. |
| 886 | * |
| 887 | * Also since userspace controls in which order properties are set this |
| 888 | * function must not do any input validation (since the state update is |
| 889 | * incomplete and hence likely inconsistent). Instead any such input |
| 890 | * validation must be done in the various atomic_check callbacks. |
| 891 | * |
| 892 | * RETURNS: |
| 893 | * |
| 894 | * 0 if the property has been found, -EINVAL if the property isn't |
| 895 | * implemented by the driver (which shouldn't ever happen, the core only |
| 896 | * asks for properties attached to this plane). No other validation is |
| 897 | * allowed by the driver. The core already checks that the property |
| 898 | * value is within the range (integer, valid enum value, ...) the driver |
| 899 | * set when registering the property. |
| 900 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 901 | int (*atomic_set_property)(struct drm_plane *plane, |
| 902 | struct drm_plane_state *state, |
| 903 | struct drm_property *property, |
| 904 | uint64_t val); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 905 | |
| 906 | /** |
| 907 | * @atomic_get_property: |
| 908 | * |
| 909 | * Reads out the decoded driver-private property. This is used to |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 910 | * implement the GETPLANE IOCTL. |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 911 | * |
| 912 | * Do not call this function directly, use |
| 913 | * drm_atomic_plane_get_property() instead. |
| 914 | * |
| 915 | * This callback is optional if the driver does not support any |
| 916 | * driver-private atomic properties. |
| 917 | * |
| 918 | * RETURNS: |
| 919 | * |
| 920 | * 0 on success, -EINVAL if the property isn't implemented by the |
| 921 | * driver (which should never happen, the core only asks for |
| 922 | * properties attached to this plane). |
| 923 | */ |
Rob Clark | ac9c925 | 2014-12-18 16:01:47 -0500 | [diff] [blame] | 924 | int (*atomic_get_property)(struct drm_plane *plane, |
| 925 | const struct drm_plane_state *state, |
| 926 | struct drm_property *property, |
| 927 | uint64_t *val); |
Benjamin Gaignard | 79190ea | 2016-06-21 16:37:09 +0200 | [diff] [blame] | 928 | /** |
| 929 | * @late_register: |
| 930 | * |
| 931 | * This optional hook can be used to register additional userspace |
| 932 | * interfaces attached to the plane like debugfs interfaces. |
| 933 | * It is called late in the driver load sequence from drm_dev_register(). |
| 934 | * Everything added from this callback should be unregistered in |
| 935 | * the early_unregister callback. |
| 936 | * |
| 937 | * Returns: |
| 938 | * |
| 939 | * 0 on success, or a negative error code on failure. |
| 940 | */ |
| 941 | int (*late_register)(struct drm_plane *plane); |
| 942 | |
| 943 | /** |
| 944 | * @early_unregister: |
| 945 | * |
| 946 | * This optional hook should be used to unregister the additional |
| 947 | * userspace interfaces attached to the plane from |
| 948 | * late_unregister(). It is called from drm_dev_unregister(), |
| 949 | * early in the driver unload sequence to disable userspace access |
| 950 | * before data structures are torndown. |
| 951 | */ |
| 952 | void (*early_unregister)(struct drm_plane *plane); |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 953 | }; |
| 954 | |
Matt Roper | e27dde3 | 2014-04-01 15:22:30 -0700 | [diff] [blame] | 955 | enum drm_plane_type { |
| 956 | DRM_PLANE_TYPE_OVERLAY, |
| 957 | DRM_PLANE_TYPE_PRIMARY, |
| 958 | DRM_PLANE_TYPE_CURSOR, |
| 959 | }; |
| 960 | |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 961 | |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 962 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 963 | * struct drm_plane - central DRM plane control structure |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 964 | * @dev: DRM device this plane belongs to |
| 965 | * @head: for list management |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 966 | * @name: human readable name, can be overwritten by the driver |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 967 | * @base: base mode object |
| 968 | * @possible_crtcs: pipes this plane can be bound to |
| 969 | * @format_types: array of formats supported by this plane |
| 970 | * @format_count: number of formats supported |
Laurent Pinchart | 7eb5f30 | 2015-03-09 10:41:07 +0200 | [diff] [blame] | 971 | * @format_default: driver hasn't supplied supported formats for the plane |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 972 | * @crtc: currently bound CRTC |
| 973 | * @fb: currently bound fb |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 974 | * @old_fb: Temporary tracking of the old fb while a modeset is ongoing. Used by |
| 975 | * drm_mode_set_config_internal() to implement correct refcounting. |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 976 | * @funcs: helper functions |
Rob Clark | 4d93914 | 2012-05-17 02:23:27 -0600 | [diff] [blame] | 977 | * @properties: property tracking for this plane |
Matt Roper | e27dde3 | 2014-04-01 15:22:30 -0700 | [diff] [blame] | 978 | * @type: type of plane (overlay, primary, cursor) |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 979 | * @state: current atomic state for this plane |
Marek Szyprowski | 44d1240d | 2016-06-13 11:11:26 +0200 | [diff] [blame] | 980 | * @zpos_property: zpos property for this plane |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 981 | * @helper_private: mid-layer private data |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 982 | */ |
| 983 | struct drm_plane { |
| 984 | struct drm_device *dev; |
| 985 | struct list_head head; |
| 986 | |
Ville Syrjälä | 9f4c97a | 2015-12-08 18:41:54 +0200 | [diff] [blame] | 987 | char *name; |
| 988 | |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 989 | /** |
| 990 | * @mutex: |
| 991 | * |
| 992 | * Protects modeset plane state, together with the mutex of &drm_crtc |
| 993 | * this plane is linked to (when active, getting actived or getting |
| 994 | * disabled). |
| 995 | */ |
Daniel Vetter | 4d02e2d | 2014-11-11 10:12:00 +0100 | [diff] [blame] | 996 | struct drm_modeset_lock mutex; |
| 997 | |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 998 | struct drm_mode_object base; |
| 999 | |
| 1000 | uint32_t possible_crtcs; |
| 1001 | uint32_t *format_types; |
Thierry Reding | 45e3743 | 2015-08-12 16:54:28 +0200 | [diff] [blame] | 1002 | unsigned int format_count; |
Laurent Pinchart | 7eb5f30 | 2015-03-09 10:41:07 +0200 | [diff] [blame] | 1003 | bool format_default; |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1004 | |
| 1005 | struct drm_crtc *crtc; |
| 1006 | struct drm_framebuffer *fb; |
| 1007 | |
Daniel Vetter | 3d30a59 | 2014-07-27 13:42:42 +0200 | [diff] [blame] | 1008 | struct drm_framebuffer *old_fb; |
| 1009 | |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1010 | const struct drm_plane_funcs *funcs; |
Rob Clark | 4d93914 | 2012-05-17 02:23:27 -0600 | [diff] [blame] | 1011 | |
| 1012 | struct drm_object_properties properties; |
Matt Roper | e27dde3 | 2014-04-01 15:22:30 -0700 | [diff] [blame] | 1013 | |
| 1014 | enum drm_plane_type type; |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1015 | |
Daniel Vetter | 9609408 | 2016-07-15 21:47:59 +0200 | [diff] [blame] | 1016 | /** |
| 1017 | * @index: Position inside the mode_config.list, can be used as an array |
| 1018 | * index. It is invariant over the lifetime of the plane. |
| 1019 | */ |
Chris Wilson | 490d3d1 | 2016-05-27 20:05:00 +0100 | [diff] [blame] | 1020 | unsigned index; |
| 1021 | |
Daniel Vetter | 4490d4c | 2015-12-04 09:45:45 +0100 | [diff] [blame] | 1022 | const struct drm_plane_helper_funcs *helper_private; |
Daniel Vetter | c2fcd27 | 2014-11-05 00:14:14 +0100 | [diff] [blame] | 1023 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1024 | struct drm_plane_state *state; |
Marek Szyprowski | 44d1240d | 2016-06-13 11:11:26 +0200 | [diff] [blame] | 1025 | |
| 1026 | struct drm_property *zpos_property; |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1027 | }; |
| 1028 | |
| 1029 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 1030 | * struct drm_bridge_funcs - drm_bridge control functions |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1031 | */ |
| 1032 | struct drm_bridge_funcs { |
Andrea Merello | cf3bef9 | 2016-08-25 11:04:32 +0200 | [diff] [blame] | 1033 | /** |
| 1034 | * @attach: |
| 1035 | * |
| 1036 | * This callback is invoked whenever our bridge is being attached to a |
| 1037 | * &drm_encoder. |
| 1038 | * |
| 1039 | * The attach callback is optional. |
| 1040 | * |
| 1041 | * RETURNS: |
| 1042 | * |
| 1043 | * Zero on success, error code on failure. |
| 1044 | */ |
Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 1045 | int (*attach)(struct drm_bridge *bridge); |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1046 | |
| 1047 | /** |
Andrea Merello | cf3bef9 | 2016-08-25 11:04:32 +0200 | [diff] [blame] | 1048 | * @detach: |
| 1049 | * |
| 1050 | * This callback is invoked whenever our bridge is being detached from a |
| 1051 | * &drm_encoder. |
| 1052 | * |
| 1053 | * The detach callback is optional. |
| 1054 | */ |
| 1055 | void (*detach)(struct drm_bridge *bridge); |
| 1056 | |
| 1057 | /** |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1058 | * @mode_fixup: |
| 1059 | * |
| 1060 | * This callback is used to validate and adjust a mode. The paramater |
| 1061 | * mode is the display mode that should be fed to the next element in |
| 1062 | * the display chain, either the final &drm_connector or the next |
| 1063 | * &drm_bridge. The parameter adjusted_mode is the input mode the bridge |
| 1064 | * requires. It can be modified by this callback and does not need to |
| 1065 | * match mode. |
| 1066 | * |
| 1067 | * This is the only hook that allows a bridge to reject a modeset. If |
| 1068 | * this function passes all other callbacks must succeed for this |
| 1069 | * configuration. |
| 1070 | * |
Andrea Merello | cf3bef9 | 2016-08-25 11:04:32 +0200 | [diff] [blame] | 1071 | * The mode_fixup callback is optional. |
| 1072 | * |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1073 | * NOTE: |
| 1074 | * |
| 1075 | * This function is called in the check phase of atomic modesets, which |
| 1076 | * can be aborted for any reason (including on userspace's request to |
| 1077 | * just check whether a configuration would be possible). Drivers MUST |
| 1078 | * NOT touch any persistent state (hardware or software) or data |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1079 | * structures except the passed in @state parameter. |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1080 | * |
| 1081 | * RETURNS: |
| 1082 | * |
| 1083 | * True if an acceptable configuration is possible, false if the modeset |
| 1084 | * operation should be rejected. |
| 1085 | */ |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1086 | bool (*mode_fixup)(struct drm_bridge *bridge, |
| 1087 | const struct drm_display_mode *mode, |
| 1088 | struct drm_display_mode *adjusted_mode); |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1089 | /** |
| 1090 | * @disable: |
| 1091 | * |
| 1092 | * This callback should disable the bridge. It is called right before |
| 1093 | * the preceding element in the display pipe is disabled. If the |
| 1094 | * preceding element is a bridge this means it's called before that |
| 1095 | * bridge's ->disable() function. If the preceding element is a |
| 1096 | * &drm_encoder it's called right before the encoder's ->disable(), |
| 1097 | * ->prepare() or ->dpms() hook from struct &drm_encoder_helper_funcs. |
| 1098 | * |
| 1099 | * The bridge can assume that the display pipe (i.e. clocks and timing |
| 1100 | * signals) feeding it is still running when this callback is called. |
Laurent Pinchart | c8a3b2a | 2016-02-26 11:51:06 +0200 | [diff] [blame] | 1101 | * |
| 1102 | * The disable callback is optional. |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1103 | */ |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1104 | void (*disable)(struct drm_bridge *bridge); |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1105 | |
| 1106 | /** |
| 1107 | * @post_disable: |
| 1108 | * |
| 1109 | * This callback should disable the bridge. It is called right after |
| 1110 | * the preceding element in the display pipe is disabled. If the |
| 1111 | * preceding element is a bridge this means it's called after that |
| 1112 | * bridge's ->post_disable() function. If the preceding element is a |
| 1113 | * &drm_encoder it's called right after the encoder's ->disable(), |
| 1114 | * ->prepare() or ->dpms() hook from struct &drm_encoder_helper_funcs. |
| 1115 | * |
| 1116 | * The bridge must assume that the display pipe (i.e. clocks and timing |
| 1117 | * singals) feeding it is no longer running when this callback is |
| 1118 | * called. |
Laurent Pinchart | c8a3b2a | 2016-02-26 11:51:06 +0200 | [diff] [blame] | 1119 | * |
| 1120 | * The post_disable callback is optional. |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1121 | */ |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1122 | void (*post_disable)(struct drm_bridge *bridge); |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1123 | |
| 1124 | /** |
| 1125 | * @mode_set: |
| 1126 | * |
| 1127 | * This callback should set the given mode on the bridge. It is called |
| 1128 | * after the ->mode_set() callback for the preceding element in the |
| 1129 | * display pipeline has been called already. The display pipe (i.e. |
| 1130 | * clocks and timing signals) is off when this function is called. |
| 1131 | */ |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1132 | void (*mode_set)(struct drm_bridge *bridge, |
| 1133 | struct drm_display_mode *mode, |
| 1134 | struct drm_display_mode *adjusted_mode); |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1135 | /** |
| 1136 | * @pre_enable: |
| 1137 | * |
| 1138 | * This callback should enable the bridge. It is called right before |
| 1139 | * the preceding element in the display pipe is enabled. If the |
| 1140 | * preceding element is a bridge this means it's called before that |
| 1141 | * bridge's ->pre_enable() function. If the preceding element is a |
| 1142 | * &drm_encoder it's called right before the encoder's ->enable(), |
| 1143 | * ->commit() or ->dpms() hook from struct &drm_encoder_helper_funcs. |
| 1144 | * |
| 1145 | * The display pipe (i.e. clocks and timing signals) feeding this bridge |
| 1146 | * will not yet be running when this callback is called. The bridge must |
| 1147 | * not enable the display link feeding the next bridge in the chain (if |
| 1148 | * there is one) when this callback is called. |
Laurent Pinchart | c8a3b2a | 2016-02-26 11:51:06 +0200 | [diff] [blame] | 1149 | * |
| 1150 | * The pre_enable callback is optional. |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1151 | */ |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1152 | void (*pre_enable)(struct drm_bridge *bridge); |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1153 | |
| 1154 | /** |
| 1155 | * @enable: |
| 1156 | * |
| 1157 | * This callback should enable the bridge. It is called right after |
| 1158 | * the preceding element in the display pipe is enabled. If the |
| 1159 | * preceding element is a bridge this means it's called after that |
| 1160 | * bridge's ->enable() function. If the preceding element is a |
| 1161 | * &drm_encoder it's called right after the encoder's ->enable(), |
| 1162 | * ->commit() or ->dpms() hook from struct &drm_encoder_helper_funcs. |
| 1163 | * |
| 1164 | * The bridge can assume that the display pipe (i.e. clocks and timing |
| 1165 | * signals) feeding it is running when this callback is called. This |
| 1166 | * callback must enable the display link feeding the next bridge in the |
| 1167 | * chain if there is one. |
Laurent Pinchart | c8a3b2a | 2016-02-26 11:51:06 +0200 | [diff] [blame] | 1168 | * |
| 1169 | * The enable callback is optional. |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1170 | */ |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1171 | void (*enable)(struct drm_bridge *bridge); |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1172 | }; |
| 1173 | |
| 1174 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 1175 | * struct drm_bridge - central DRM bridge control structure |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1176 | * @dev: DRM device this bridge belongs to |
Archit Taneja | 862e686 | 2015-05-21 11:03:16 +0530 | [diff] [blame] | 1177 | * @encoder: encoder to which this bridge is connected |
| 1178 | * @next: the next bridge in the encoder chain |
Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 1179 | * @of_node: device node pointer to the bridge |
| 1180 | * @list: to keep track of all added bridges |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1181 | * @funcs: control functions |
| 1182 | * @driver_private: pointer to the bridge driver's internal context |
| 1183 | */ |
| 1184 | struct drm_bridge { |
| 1185 | struct drm_device *dev; |
Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 1186 | struct drm_encoder *encoder; |
Archit Taneja | 862e686 | 2015-05-21 11:03:16 +0530 | [diff] [blame] | 1187 | struct drm_bridge *next; |
Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 1188 | #ifdef CONFIG_OF |
| 1189 | struct device_node *of_node; |
| 1190 | #endif |
| 1191 | struct list_head list; |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1192 | |
| 1193 | const struct drm_bridge_funcs *funcs; |
| 1194 | void *driver_private; |
| 1195 | }; |
| 1196 | |
Daniel Vetter | 3b24f7d | 2016-06-08 14:19:00 +0200 | [diff] [blame] | 1197 | /** |
| 1198 | * struct drm_crtc_commit - track modeset commits on a CRTC |
| 1199 | * |
| 1200 | * This structure is used to track pending modeset changes and atomic commit on |
| 1201 | * a per-CRTC basis. Since updating the list should never block this structure |
| 1202 | * is reference counted to allow waiters to safely wait on an event to complete, |
| 1203 | * without holding any locks. |
| 1204 | * |
| 1205 | * It has 3 different events in total to allow a fine-grained synchronization |
| 1206 | * between outstanding updates:: |
| 1207 | * |
| 1208 | * atomic commit thread hardware |
| 1209 | * |
| 1210 | * write new state into hardware ----> ... |
| 1211 | * signal hw_done |
| 1212 | * switch to new state on next |
| 1213 | * ... v/hblank |
| 1214 | * |
| 1215 | * wait for buffers to show up ... |
| 1216 | * |
| 1217 | * ... send completion irq |
| 1218 | * irq handler signals flip_done |
| 1219 | * cleanup old buffers |
| 1220 | * |
| 1221 | * signal cleanup_done |
| 1222 | * |
| 1223 | * wait for flip_done <---- |
| 1224 | * clean up atomic state |
| 1225 | * |
| 1226 | * The important bit to know is that cleanup_done is the terminal event, but the |
| 1227 | * ordering between flip_done and hw_done is entirely up to the specific driver |
| 1228 | * and modeset state change. |
| 1229 | * |
| 1230 | * For an implementation of how to use this look at |
| 1231 | * drm_atomic_helper_setup_commit() from the atomic helper library. |
| 1232 | */ |
| 1233 | struct drm_crtc_commit { |
| 1234 | /** |
| 1235 | * @crtc: |
| 1236 | * |
| 1237 | * DRM CRTC for this commit. |
| 1238 | */ |
| 1239 | struct drm_crtc *crtc; |
| 1240 | |
| 1241 | /** |
| 1242 | * @ref: |
| 1243 | * |
| 1244 | * Reference count for this structure. Needed to allow blocking on |
| 1245 | * completions without the risk of the completion disappearing |
| 1246 | * meanwhile. |
| 1247 | */ |
| 1248 | struct kref ref; |
| 1249 | |
| 1250 | /** |
| 1251 | * @flip_done: |
| 1252 | * |
| 1253 | * Will be signaled when the hardware has flipped to the new set of |
| 1254 | * buffers. Signals at the same time as when the drm event for this |
| 1255 | * commit is sent to userspace, or when an out-fence is singalled. Note |
| 1256 | * that for most hardware, in most cases this happens after @hw_done is |
| 1257 | * signalled. |
| 1258 | */ |
| 1259 | struct completion flip_done; |
| 1260 | |
| 1261 | /** |
| 1262 | * @hw_done: |
| 1263 | * |
| 1264 | * Will be signalled when all hw register changes for this commit have |
| 1265 | * been written out. Especially when disabling a pipe this can be much |
| 1266 | * later than than @flip_done, since that can signal already when the |
| 1267 | * screen goes black, whereas to fully shut down a pipe more register |
| 1268 | * I/O is required. |
| 1269 | * |
| 1270 | * Note that this does not need to include separately reference-counted |
| 1271 | * resources like backing storage buffer pinning, or runtime pm |
| 1272 | * management. |
| 1273 | */ |
| 1274 | struct completion hw_done; |
| 1275 | |
| 1276 | /** |
| 1277 | * @cleanup_done: |
| 1278 | * |
| 1279 | * Will be signalled after old buffers have been cleaned up by calling |
| 1280 | * drm_atomic_helper_cleanup_planes(). Since this can only happen after |
| 1281 | * a vblank wait completed it might be a bit later. This completion is |
| 1282 | * useful to throttle updates and avoid hardware updates getting ahead |
| 1283 | * of the buffer cleanup too much. |
| 1284 | */ |
| 1285 | struct completion cleanup_done; |
| 1286 | |
| 1287 | /** |
| 1288 | * @commit_entry: |
| 1289 | * |
| 1290 | * Entry on the per-CRTC commit_list. Protected by crtc->commit_lock. |
| 1291 | */ |
| 1292 | struct list_head commit_entry; |
| 1293 | |
| 1294 | /** |
| 1295 | * @event: |
| 1296 | * |
| 1297 | * &drm_pending_vblank_event pointer to clean up private events. |
| 1298 | */ |
| 1299 | struct drm_pending_vblank_event *event; |
| 1300 | }; |
| 1301 | |
Daniel Vetter | b8b5342 | 2016-06-02 00:06:33 +0200 | [diff] [blame] | 1302 | struct __drm_planes_state { |
| 1303 | struct drm_plane *ptr; |
| 1304 | struct drm_plane_state *state; |
| 1305 | }; |
| 1306 | |
Daniel Vetter | 5d943aa6 | 2016-06-02 00:06:34 +0200 | [diff] [blame] | 1307 | struct __drm_crtcs_state { |
| 1308 | struct drm_crtc *ptr; |
| 1309 | struct drm_crtc_state *state; |
Daniel Vetter | 3b24f7d | 2016-06-08 14:19:00 +0200 | [diff] [blame] | 1310 | struct drm_crtc_commit *commit; |
Daniel Vetter | 5d943aa6 | 2016-06-02 00:06:34 +0200 | [diff] [blame] | 1311 | }; |
| 1312 | |
Daniel Vetter | 63e83c1 | 2016-06-02 00:06:32 +0200 | [diff] [blame] | 1313 | struct __drm_connnectors_state { |
| 1314 | struct drm_connector *ptr; |
| 1315 | struct drm_connector_state *state; |
| 1316 | }; |
| 1317 | |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1318 | /** |
Rob Clark | 08855fa | 2015-03-11 10:23:09 -0400 | [diff] [blame] | 1319 | * struct drm_atomic_state - the global state object for atomic updates |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1320 | * @dev: parent DRM device |
Rob Clark | d34f20d | 2014-12-18 16:01:56 -0500 | [diff] [blame] | 1321 | * @allow_modeset: allow full modeset |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 1322 | * @legacy_cursor_update: hint to enforce legacy cursor IOCTL semantics |
Maarten Lankhorst | 40616a2 | 2016-03-03 10:17:39 +0100 | [diff] [blame] | 1323 | * @legacy_set_config: Disable conflicting encoders instead of failing with -EINVAL. |
Daniel Vetter | b8b5342 | 2016-06-02 00:06:33 +0200 | [diff] [blame] | 1324 | * @planes: pointer to array of structures with per-plane data |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1325 | * @crtcs: pointer to array of CRTC pointers |
Daniel Vetter | f52b69f1 | 2014-11-19 18:38:08 +0100 | [diff] [blame] | 1326 | * @num_connector: size of the @connectors and @connector_states arrays |
Daniel Vetter | 63e83c1 | 2016-06-02 00:06:32 +0200 | [diff] [blame] | 1327 | * @connectors: pointer to array of structures with per-connector data |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1328 | * @acquire_ctx: acquire context for this atomic modeset state update |
| 1329 | */ |
| 1330 | struct drm_atomic_state { |
| 1331 | struct drm_device *dev; |
Rob Clark | d34f20d | 2014-12-18 16:01:56 -0500 | [diff] [blame] | 1332 | bool allow_modeset : 1; |
Daniel Vetter | f02ad90 | 2015-01-22 16:36:23 +0100 | [diff] [blame] | 1333 | bool legacy_cursor_update : 1; |
Maarten Lankhorst | 40616a2 | 2016-03-03 10:17:39 +0100 | [diff] [blame] | 1334 | bool legacy_set_config : 1; |
Daniel Vetter | b8b5342 | 2016-06-02 00:06:33 +0200 | [diff] [blame] | 1335 | struct __drm_planes_state *planes; |
Daniel Vetter | 5d943aa6 | 2016-06-02 00:06:34 +0200 | [diff] [blame] | 1336 | struct __drm_crtcs_state *crtcs; |
Daniel Vetter | f52b69f1 | 2014-11-19 18:38:08 +0100 | [diff] [blame] | 1337 | int num_connector; |
Daniel Vetter | 63e83c1 | 2016-06-02 00:06:32 +0200 | [diff] [blame] | 1338 | struct __drm_connnectors_state *connectors; |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1339 | |
| 1340 | struct drm_modeset_acquire_ctx *acquire_ctx; |
Daniel Vetter | 3b24f7d | 2016-06-08 14:19:00 +0200 | [diff] [blame] | 1341 | |
| 1342 | /** |
| 1343 | * @commit_work: |
| 1344 | * |
| 1345 | * Work item which can be used by the driver or helpers to execute the |
| 1346 | * commit without blocking. |
| 1347 | */ |
| 1348 | struct work_struct commit_work; |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1349 | }; |
| 1350 | |
| 1351 | |
| 1352 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 1353 | * struct drm_mode_set - new values for a CRTC config change |
Jesse Barnes | ef27351 | 2011-11-07 12:03:19 -0800 | [diff] [blame] | 1354 | * @fb: framebuffer to use for new config |
| 1355 | * @crtc: CRTC whose configuration we're about to change |
| 1356 | * @mode: mode timings to use |
| 1357 | * @x: position of this CRTC relative to @fb |
| 1358 | * @y: position of this CRTC relative to @fb |
| 1359 | * @connectors: array of connectors to drive with this CRTC if possible |
| 1360 | * @num_connectors: size of @connectors array |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1361 | * |
| 1362 | * Represents a single crtc the connectors that it drives with what mode |
| 1363 | * and from which framebuffer it scans out from. |
| 1364 | * |
| 1365 | * This is used to set modes. |
| 1366 | */ |
| 1367 | struct drm_mode_set { |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1368 | struct drm_framebuffer *fb; |
| 1369 | struct drm_crtc *crtc; |
| 1370 | struct drm_display_mode *mode; |
| 1371 | |
| 1372 | uint32_t x; |
| 1373 | uint32_t y; |
| 1374 | |
| 1375 | struct drm_connector **connectors; |
| 1376 | size_t num_connectors; |
| 1377 | }; |
| 1378 | |
| 1379 | /** |
Jesse Barnes | 550cebc | 2011-11-07 12:03:20 -0800 | [diff] [blame] | 1380 | * struct drm_mode_config_funcs - basic driver provided mode setting functions |
Jesse Barnes | 550cebc | 2011-11-07 12:03:20 -0800 | [diff] [blame] | 1381 | * |
| 1382 | * Some global (i.e. not per-CRTC, connector, etc) mode setting functions that |
| 1383 | * involve drivers. |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1384 | */ |
| 1385 | struct drm_mode_config_funcs { |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1386 | /** |
| 1387 | * @fb_create: |
| 1388 | * |
| 1389 | * Create a new framebuffer object. The core does basic checks on the |
| 1390 | * requested metadata, but most of that is left to the driver. See |
| 1391 | * struct &drm_mode_fb_cmd2 for details. |
| 1392 | * |
Daniel Vetter | d55f532 | 2015-12-08 09:49:19 +0100 | [diff] [blame] | 1393 | * If the parameters are deemed valid and the backing storage objects in |
| 1394 | * the underlying memory manager all exist, then the driver allocates |
| 1395 | * a new &drm_framebuffer structure, subclassed to contain |
| 1396 | * driver-specific information (like the internal native buffer object |
| 1397 | * references). It also needs to fill out all relevant metadata, which |
| 1398 | * should be done by calling drm_helper_mode_fill_fb_struct(). |
| 1399 | * |
| 1400 | * The initialization is finalized by calling drm_framebuffer_init(), |
| 1401 | * which registers the framebuffer and makes it accessible to other |
| 1402 | * threads. |
| 1403 | * |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1404 | * RETURNS: |
| 1405 | * |
| 1406 | * A new framebuffer with an initial reference count of 1 or a negative |
| 1407 | * error code encoded with ERR_PTR(). |
| 1408 | */ |
Jesse Barnes | 550cebc | 2011-11-07 12:03:20 -0800 | [diff] [blame] | 1409 | struct drm_framebuffer *(*fb_create)(struct drm_device *dev, |
| 1410 | struct drm_file *file_priv, |
Ville Syrjälä | 1eb8345 | 2015-11-11 19:11:29 +0200 | [diff] [blame] | 1411 | const struct drm_mode_fb_cmd2 *mode_cmd); |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1412 | |
| 1413 | /** |
| 1414 | * @output_poll_changed: |
| 1415 | * |
| 1416 | * Callback used by helpers to inform the driver of output configuration |
| 1417 | * changes. |
| 1418 | * |
| 1419 | * Drivers implementing fbdev emulation with the helpers can call |
| 1420 | * drm_fb_helper_hotplug_changed from this hook to inform the fbdev |
| 1421 | * helper of output changes. |
| 1422 | * |
| 1423 | * FIXME: |
| 1424 | * |
| 1425 | * Except that there's no vtable for device-level helper callbacks |
| 1426 | * there's no reason this is a core function. |
| 1427 | */ |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 1428 | void (*output_poll_changed)(struct drm_device *dev); |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1429 | |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1430 | /** |
| 1431 | * @atomic_check: |
| 1432 | * |
| 1433 | * This is the only hook to validate an atomic modeset update. This |
| 1434 | * function must reject any modeset and state changes which the hardware |
| 1435 | * or driver doesn't support. This includes but is of course not limited |
| 1436 | * to: |
| 1437 | * |
| 1438 | * - Checking that the modes, framebuffers, scaling and placement |
| 1439 | * requirements and so on are within the limits of the hardware. |
| 1440 | * |
| 1441 | * - Checking that any hidden shared resources are not oversubscribed. |
| 1442 | * This can be shared PLLs, shared lanes, overall memory bandwidth, |
| 1443 | * display fifo space (where shared between planes or maybe even |
| 1444 | * CRTCs). |
| 1445 | * |
| 1446 | * - Checking that virtualized resources exported to userspace are not |
| 1447 | * oversubscribed. For various reasons it can make sense to expose |
| 1448 | * more planes, crtcs or encoders than which are physically there. One |
| 1449 | * example is dual-pipe operations (which generally should be hidden |
| 1450 | * from userspace if when lockstepped in hardware, exposed otherwise), |
| 1451 | * where a plane might need 1 hardware plane (if it's just on one |
| 1452 | * pipe), 2 hardware planes (when it spans both pipes) or maybe even |
| 1453 | * shared a hardware plane with a 2nd plane (if there's a compatible |
| 1454 | * plane requested on the area handled by the other pipe). |
| 1455 | * |
| 1456 | * - Check that any transitional state is possible and that if |
| 1457 | * requested, the update can indeed be done in the vblank period |
| 1458 | * without temporarily disabling some functions. |
| 1459 | * |
| 1460 | * - Check any other constraints the driver or hardware might have. |
| 1461 | * |
| 1462 | * - This callback also needs to correctly fill out the &drm_crtc_state |
| 1463 | * in this update to make sure that drm_atomic_crtc_needs_modeset() |
| 1464 | * reflects the nature of the possible update and returns true if and |
| 1465 | * only if the update cannot be applied without tearing within one |
| 1466 | * vblank on that CRTC. The core uses that information to reject |
| 1467 | * updates which require a full modeset (i.e. blanking the screen, or |
| 1468 | * at least pausing updates for a substantial amount of time) if |
| 1469 | * userspace has disallowed that in its request. |
| 1470 | * |
| 1471 | * - The driver also does not need to repeat basic input validation |
| 1472 | * like done for the corresponding legacy entry points. The core does |
| 1473 | * that before calling this hook. |
| 1474 | * |
| 1475 | * See the documentation of @atomic_commit for an exhaustive list of |
| 1476 | * error conditions which don't have to be checked at the |
| 1477 | * ->atomic_check() stage? |
| 1478 | * |
| 1479 | * See the documentation for struct &drm_atomic_state for how exactly |
| 1480 | * an atomic modeset update is described. |
| 1481 | * |
| 1482 | * Drivers using the atomic helpers can implement this hook using |
| 1483 | * drm_atomic_helper_check(), or one of the exported sub-functions of |
| 1484 | * it. |
| 1485 | * |
| 1486 | * RETURNS: |
| 1487 | * |
| 1488 | * 0 on success or one of the below negative error codes: |
| 1489 | * |
| 1490 | * - -EINVAL, if any of the above constraints are violated. |
| 1491 | * |
| 1492 | * - -EDEADLK, when returned from an attempt to acquire an additional |
| 1493 | * &drm_modeset_lock through drm_modeset_lock(). |
| 1494 | * |
| 1495 | * - -ENOMEM, if allocating additional state sub-structures failed due |
| 1496 | * to lack of memory. |
| 1497 | * |
| 1498 | * - -EINTR, -EAGAIN or -ERESTARTSYS, if the IOCTL should be restarted. |
| 1499 | * This can either be due to a pending signal, or because the driver |
| 1500 | * needs to completely bail out to recover from an exceptional |
| 1501 | * situation like a GPU hang. From a userspace point all errors are |
| 1502 | * treated equally. |
| 1503 | */ |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1504 | int (*atomic_check)(struct drm_device *dev, |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1505 | struct drm_atomic_state *state); |
| 1506 | |
| 1507 | /** |
| 1508 | * @atomic_commit: |
| 1509 | * |
| 1510 | * This is the only hook to commit an atomic modeset update. The core |
| 1511 | * guarantees that @atomic_check has been called successfully before |
| 1512 | * calling this function, and that nothing has been changed in the |
| 1513 | * interim. |
| 1514 | * |
| 1515 | * See the documentation for struct &drm_atomic_state for how exactly |
| 1516 | * an atomic modeset update is described. |
| 1517 | * |
| 1518 | * Drivers using the atomic helpers can implement this hook using |
| 1519 | * drm_atomic_helper_commit(), or one of the exported sub-functions of |
| 1520 | * it. |
| 1521 | * |
Maarten Lankhorst | 286dbb8 | 2016-04-26 16:11:34 +0200 | [diff] [blame] | 1522 | * Nonblocking commits (as indicated with the nonblock parameter) must |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1523 | * do any preparatory work which might result in an unsuccessful commit |
| 1524 | * in the context of this callback. The only exceptions are hardware |
| 1525 | * errors resulting in -EIO. But even in that case the driver must |
| 1526 | * ensure that the display pipe is at least running, to avoid |
| 1527 | * compositors crashing when pageflips don't work. Anything else, |
| 1528 | * specifically committing the update to the hardware, should be done |
| 1529 | * without blocking the caller. For updates which do not require a |
| 1530 | * modeset this must be guaranteed. |
| 1531 | * |
| 1532 | * The driver must wait for any pending rendering to the new |
| 1533 | * framebuffers to complete before executing the flip. It should also |
| 1534 | * wait for any pending rendering from other drivers if the underlying |
Maarten Lankhorst | 286dbb8 | 2016-04-26 16:11:34 +0200 | [diff] [blame] | 1535 | * buffer is a shared dma-buf. Nonblocking commits must not wait for |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1536 | * rendering in the context of this callback. |
| 1537 | * |
| 1538 | * An application can request to be notified when the atomic commit has |
| 1539 | * completed. These events are per-CRTC and can be distinguished by the |
| 1540 | * CRTC index supplied in &drm_event to userspace. |
| 1541 | * |
| 1542 | * The drm core will supply a struct &drm_event in the event |
| 1543 | * member of each CRTC's &drm_crtc_state structure. This can be handled by the |
| 1544 | * drm_crtc_send_vblank_event() function, which the driver should call on |
| 1545 | * the provided event upon completion of the atomic commit. Note that if |
| 1546 | * the driver supports vblank signalling and timestamping the vblank |
| 1547 | * counters and timestamps must agree with the ones returned from page |
| 1548 | * flip events. With the current vblank helper infrastructure this can |
| 1549 | * be achieved by holding a vblank reference while the page flip is |
| 1550 | * pending, acquired through drm_crtc_vblank_get() and released with |
| 1551 | * drm_crtc_vblank_put(). Drivers are free to implement their own vblank |
| 1552 | * counter and timestamp tracking though, e.g. if they have accurate |
| 1553 | * timestamp registers in hardware. |
| 1554 | * |
| 1555 | * NOTE: |
| 1556 | * |
| 1557 | * Drivers are not allowed to shut down any display pipe successfully |
| 1558 | * enabled through an atomic commit on their own. Doing so can result in |
| 1559 | * compositors crashing if a page flip is suddenly rejected because the |
| 1560 | * pipe is off. |
| 1561 | * |
| 1562 | * RETURNS: |
| 1563 | * |
| 1564 | * 0 on success or one of the below negative error codes: |
| 1565 | * |
Maarten Lankhorst | 286dbb8 | 2016-04-26 16:11:34 +0200 | [diff] [blame] | 1566 | * - -EBUSY, if a nonblocking updated is requested and there is |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1567 | * an earlier updated pending. Drivers are allowed to support a queue |
| 1568 | * of outstanding updates, but currently no driver supports that. |
| 1569 | * Note that drivers must wait for preceding updates to complete if a |
| 1570 | * synchronous update is requested, they are not allowed to fail the |
| 1571 | * commit in that case. |
| 1572 | * |
| 1573 | * - -ENOMEM, if the driver failed to allocate memory. Specifically |
| 1574 | * this can happen when trying to pin framebuffers, which must only |
| 1575 | * be done when committing the state. |
| 1576 | * |
| 1577 | * - -ENOSPC, as a refinement of the more generic -ENOMEM to indicate |
| 1578 | * that the driver has run out of vram, iommu space or similar GPU |
| 1579 | * address space needed for framebuffer. |
| 1580 | * |
| 1581 | * - -EIO, if the hardware completely died. |
| 1582 | * |
| 1583 | * - -EINTR, -EAGAIN or -ERESTARTSYS, if the IOCTL should be restarted. |
| 1584 | * This can either be due to a pending signal, or because the driver |
| 1585 | * needs to completely bail out to recover from an exceptional |
| 1586 | * situation like a GPU hang. From a userspace point of view all errors are |
| 1587 | * treated equally. |
| 1588 | * |
| 1589 | * This list is exhaustive. Specifically this hook is not allowed to |
| 1590 | * return -EINVAL (any invalid requests should be caught in |
| 1591 | * @atomic_check) or -EDEADLK (this function must not acquire |
| 1592 | * additional modeset locks). |
| 1593 | */ |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1594 | int (*atomic_commit)(struct drm_device *dev, |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1595 | struct drm_atomic_state *state, |
Maarten Lankhorst | 286dbb8 | 2016-04-26 16:11:34 +0200 | [diff] [blame] | 1596 | bool nonblock); |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1597 | |
| 1598 | /** |
| 1599 | * @atomic_state_alloc: |
| 1600 | * |
| 1601 | * This optional hook can be used by drivers that want to subclass struct |
| 1602 | * &drm_atomic_state to be able to track their own driver-private global |
| 1603 | * state easily. If this hook is implemented, drivers must also |
| 1604 | * implement @atomic_state_clear and @atomic_state_free. |
| 1605 | * |
| 1606 | * RETURNS: |
| 1607 | * |
| 1608 | * A new &drm_atomic_state on success or NULL on failure. |
| 1609 | */ |
Maarten Lankhorst | 036ef57 | 2015-05-18 10:06:40 +0200 | [diff] [blame] | 1610 | struct drm_atomic_state *(*atomic_state_alloc)(struct drm_device *dev); |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1611 | |
| 1612 | /** |
| 1613 | * @atomic_state_clear: |
| 1614 | * |
| 1615 | * This hook must clear any driver private state duplicated into the |
| 1616 | * passed-in &drm_atomic_state. This hook is called when the caller |
| 1617 | * encountered a &drm_modeset_lock deadlock and needs to drop all |
| 1618 | * already acquired locks as part of the deadlock avoidance dance |
| 1619 | * implemented in drm_modeset_lock_backoff(). |
| 1620 | * |
| 1621 | * Any duplicated state must be invalidated since a concurrent atomic |
| 1622 | * update might change it, and the drm atomic interfaces always apply |
| 1623 | * updates as relative changes to the current state. |
| 1624 | * |
| 1625 | * Drivers that implement this must call drm_atomic_state_default_clear() |
| 1626 | * to clear common state. |
| 1627 | */ |
Maarten Lankhorst | 036ef57 | 2015-05-18 10:06:40 +0200 | [diff] [blame] | 1628 | void (*atomic_state_clear)(struct drm_atomic_state *state); |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1629 | |
| 1630 | /** |
| 1631 | * @atomic_state_free: |
| 1632 | * |
| 1633 | * This hook needs driver private resources and the &drm_atomic_state |
| 1634 | * itself. Note that the core first calls drm_atomic_state_clear() to |
| 1635 | * avoid code duplicate between the clear and free hooks. |
| 1636 | * |
| 1637 | * Drivers that implement this must call drm_atomic_state_default_free() |
| 1638 | * to release common resources. |
| 1639 | */ |
Maarten Lankhorst | 036ef57 | 2015-05-18 10:06:40 +0200 | [diff] [blame] | 1640 | void (*atomic_state_free)(struct drm_atomic_state *state); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1641 | }; |
| 1642 | |
Jesse Barnes | c1aaca2 | 2011-11-07 12:03:21 -0800 | [diff] [blame] | 1643 | /** |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1644 | * struct drm_mode_config - Mode configuration control structure |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 1645 | * @mutex: mutex protecting KMS related lists and structures |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1646 | * @connection_mutex: ww mutex protecting connector state and routing |
| 1647 | * @acquire_ctx: global implicit acquire context used by atomic drivers for |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 1648 | * legacy IOCTLs |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1649 | * @fb_lock: mutex to protect fb state and lists |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 1650 | * @num_fb: number of fbs available |
| 1651 | * @fb_list: list of framebuffers available |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 1652 | * @num_encoder: number of encoders on this device |
| 1653 | * @encoder_list: list of encoder objects |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1654 | * @num_overlay_plane: number of overlay planes on this device |
| 1655 | * @num_total_plane: number of universal (i.e. with primary/curso) planes on this device |
| 1656 | * @plane_list: list of plane objects |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 1657 | * @num_crtc: number of CRTCs on this device |
| 1658 | * @crtc_list: list of CRTC objects |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1659 | * @property_list: list of property objects |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 1660 | * @min_width: minimum pixel width on this device |
| 1661 | * @min_height: minimum pixel height on this device |
| 1662 | * @max_width: maximum pixel width on this device |
| 1663 | * @max_height: maximum pixel height on this device |
| 1664 | * @funcs: core driver provided mode setting functions |
| 1665 | * @fb_base: base address of the framebuffer |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1666 | * @poll_enabled: track polling support for this device |
| 1667 | * @poll_running: track polling status for this device |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 1668 | * @delayed_event: track delayed poll uevent deliver for this device |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 1669 | * @output_poll_work: delayed work for polling in process context |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1670 | * @property_blob_list: list of all the blob property objects |
Daniel Stone | 8fb6e7a | 2015-04-20 19:22:54 +0100 | [diff] [blame] | 1671 | * @blob_lock: mutex for blob property allocation and management |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 1672 | * @*_property: core property tracking |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1673 | * @preferred_depth: preferred RBG pixel depth, used by fb helpers |
| 1674 | * @prefer_shadow: hint to userspace to prefer shadow-fb rendering |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1675 | * @cursor_width: hint to userspace for max cursor width |
| 1676 | * @cursor_height: hint to userspace for max cursor height |
Daniel Vetter | 9f2a795 | 2016-06-08 14:19:02 +0200 | [diff] [blame] | 1677 | * @helper_private: mid-layer private data |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1678 | * |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 1679 | * Core mode resource tracking structure. All CRTC, encoders, and connectors |
| 1680 | * enumerated by the driver are added here, as are global properties. Some |
| 1681 | * global restrictions are also here, e.g. dimension restrictions. |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1682 | */ |
| 1683 | struct drm_mode_config { |
Jesse Barnes | ad2563c | 2009-01-19 17:21:45 +1000 | [diff] [blame] | 1684 | struct mutex mutex; /* protects configuration (mode lists etc.) */ |
Rob Clark | 51fd371 | 2013-11-19 12:10:12 -0500 | [diff] [blame] | 1685 | struct drm_modeset_lock connection_mutex; /* protects connector->encoder and encoder->crtc links */ |
| 1686 | 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] | 1687 | |
| 1688 | /** |
| 1689 | * @idr_mutex: |
| 1690 | * |
| 1691 | * Mutex for KMS ID allocation and management. Protects both @crtc_idr |
| 1692 | * and @tile_idr. |
| 1693 | */ |
| 1694 | struct mutex idr_mutex; |
| 1695 | |
| 1696 | /** |
| 1697 | * @crtc_idr: |
| 1698 | * |
| 1699 | * Main KMS ID tracking object. Use this idr for all IDs, fb, crtc, |
| 1700 | * connector, modes - just makes life easier to have only one. |
| 1701 | */ |
| 1702 | struct idr crtc_idr; |
| 1703 | |
| 1704 | /** |
| 1705 | * @tile_idr: |
| 1706 | * |
| 1707 | * Use this idr for allocating new IDs for tiled sinks like use in some |
| 1708 | * high-res DP MST screens. |
| 1709 | */ |
| 1710 | struct idr tile_idr; |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1711 | |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1712 | struct mutex fb_lock; /* proctects global and per-file fb lists */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1713 | int num_fb; |
| 1714 | struct list_head fb_list; |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 1715 | |
Daniel Vetter | 9609408 | 2016-07-15 21:47:59 +0200 | [diff] [blame] | 1716 | /** |
| 1717 | * @num_connector: Number of connectors on this device. |
| 1718 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1719 | int num_connector; |
Daniel Vetter | 9609408 | 2016-07-15 21:47:59 +0200 | [diff] [blame] | 1720 | /** |
| 1721 | * @connector_ida: ID allocator for connector indices. |
| 1722 | */ |
Maarten Lankhorst | 5fff80b | 2016-02-17 08:32:05 +0100 | [diff] [blame] | 1723 | struct ida connector_ida; |
Daniel Vetter | 9609408 | 2016-07-15 21:47:59 +0200 | [diff] [blame] | 1724 | /** |
| 1725 | * @connector_list: List of connector objects. |
| 1726 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1727 | struct list_head connector_list; |
| 1728 | int num_encoder; |
| 1729 | struct list_head encoder_list; |
Matt Roper | e27dde3 | 2014-04-01 15:22:30 -0700 | [diff] [blame] | 1730 | |
| 1731 | /* |
| 1732 | * Track # of overlay planes separately from # of total planes. By |
| 1733 | * default we only advertise overlay planes to userspace; if userspace |
| 1734 | * sets the "universal plane" capability bit, we'll go ahead and |
| 1735 | * expose all planes. |
| 1736 | */ |
| 1737 | int num_overlay_plane; |
| 1738 | int num_total_plane; |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1739 | struct list_head plane_list; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1740 | |
| 1741 | int num_crtc; |
| 1742 | struct list_head crtc_list; |
| 1743 | |
| 1744 | struct list_head property_list; |
| 1745 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1746 | int min_width, min_height; |
| 1747 | int max_width, max_height; |
Laurent Pinchart | e6ecefa | 2012-05-17 13:27:23 +0200 | [diff] [blame] | 1748 | const struct drm_mode_config_funcs *funcs; |
Benjamin Herrenschmidt | d883f7f | 2009-02-02 16:55:45 +1100 | [diff] [blame] | 1749 | resource_size_t fb_base; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1750 | |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 1751 | /* output poll support */ |
| 1752 | bool poll_enabled; |
Daniel Vetter | 905bc9f | 2012-10-23 18:23:36 +0000 | [diff] [blame] | 1753 | bool poll_running; |
Daniel Vetter | 162b6a5 | 2015-01-21 08:45:21 +0100 | [diff] [blame] | 1754 | bool delayed_event; |
Tejun Heo | 991ea75 | 2010-07-20 22:09:02 +0200 | [diff] [blame] | 1755 | struct delayed_work output_poll_work; |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 1756 | |
Daniel Stone | 8fb6e7a | 2015-04-20 19:22:54 +0100 | [diff] [blame] | 1757 | struct mutex blob_lock; |
| 1758 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1759 | /* pointers to standard properties */ |
| 1760 | struct list_head property_blob_list; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1761 | /** |
| 1762 | * @edid_property: Default connector property to hold the EDID of the |
| 1763 | * currently connected sink, if any. |
| 1764 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1765 | struct drm_property *edid_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1766 | /** |
| 1767 | * @dpms_property: Default connector property to control the |
| 1768 | * connector's DPMS state. |
| 1769 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1770 | struct drm_property *dpms_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1771 | /** |
| 1772 | * @path_property: Default connector property to hold the DP MST path |
| 1773 | * for the port. |
| 1774 | */ |
Dave Airlie | 43aba7e | 2014-06-05 14:01:31 +1000 | [diff] [blame] | 1775 | struct drm_property *path_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1776 | /** |
| 1777 | * @tile_property: Default connector property to store the tile |
| 1778 | * position of a tiled screen, for sinks which need to be driven with |
| 1779 | * multiple CRTCs. |
| 1780 | */ |
Dave Airlie | 6f134d7 | 2014-10-20 16:30:50 +1000 | [diff] [blame] | 1781 | struct drm_property *tile_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1782 | /** |
| 1783 | * @plane_type_property: Default plane property to differentiate |
| 1784 | * CURSOR, PRIMARY and OVERLAY legacy uses of planes. |
| 1785 | */ |
Rob Clark | 9922ab5 | 2014-04-01 20:16:57 -0400 | [diff] [blame] | 1786 | struct drm_property *plane_type_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1787 | /** |
| 1788 | * @rotation_property: Optional property for planes or CRTCs to specifiy |
| 1789 | * rotation. |
| 1790 | */ |
Sonika Jindal | 2a297cc | 2014-08-05 11:26:54 +0530 | [diff] [blame] | 1791 | struct drm_property *rotation_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1792 | /** |
| 1793 | * @prop_src_x: Default atomic plane property for the plane source |
| 1794 | * position in the connected &drm_framebuffer. |
| 1795 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1796 | struct drm_property *prop_src_x; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1797 | /** |
| 1798 | * @prop_src_y: Default atomic plane property for the plane source |
| 1799 | * position in the connected &drm_framebuffer. |
| 1800 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1801 | struct drm_property *prop_src_y; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1802 | /** |
| 1803 | * @prop_src_w: Default atomic plane property for the plane source |
| 1804 | * position in the connected &drm_framebuffer. |
| 1805 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1806 | struct drm_property *prop_src_w; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1807 | /** |
| 1808 | * @prop_src_h: Default atomic plane property for the plane source |
| 1809 | * position in the connected &drm_framebuffer. |
| 1810 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1811 | struct drm_property *prop_src_h; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1812 | /** |
| 1813 | * @prop_crtc_x: Default atomic plane property for the plane destination |
| 1814 | * position in the &drm_crtc is is being shown on. |
| 1815 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1816 | struct drm_property *prop_crtc_x; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1817 | /** |
| 1818 | * @prop_crtc_y: Default atomic plane property for the plane destination |
| 1819 | * position in the &drm_crtc is is being shown on. |
| 1820 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1821 | struct drm_property *prop_crtc_y; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1822 | /** |
| 1823 | * @prop_crtc_w: Default atomic plane property for the plane destination |
| 1824 | * position in the &drm_crtc is is being shown on. |
| 1825 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1826 | struct drm_property *prop_crtc_w; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1827 | /** |
| 1828 | * @prop_crtc_h: Default atomic plane property for the plane destination |
| 1829 | * position in the &drm_crtc is is being shown on. |
| 1830 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1831 | struct drm_property *prop_crtc_h; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1832 | /** |
| 1833 | * @prop_fb_id: Default atomic plane property to specify the |
| 1834 | * &drm_framebuffer. |
| 1835 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1836 | struct drm_property *prop_fb_id; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1837 | /** |
| 1838 | * @prop_crtc_id: Default atomic plane property to specify the |
| 1839 | * &drm_crtc. |
| 1840 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 1841 | struct drm_property *prop_crtc_id; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1842 | /** |
| 1843 | * @prop_active: Default atomic CRTC property to control the active |
| 1844 | * state, which is the simplified implementation for DPMS in atomic |
| 1845 | * drivers. |
| 1846 | */ |
Daniel Vetter | eab3bbe | 2015-01-22 16:36:21 +0100 | [diff] [blame] | 1847 | struct drm_property *prop_active; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1848 | /** |
| 1849 | * @prop_mode_id: Default atomic CRTC property to set the mode for a |
| 1850 | * CRTC. A 0 mode implies that the CRTC is entirely disabled - all |
| 1851 | * connectors must be of and active must be set to disabled, too. |
| 1852 | */ |
Daniel Stone | 955f3c3 | 2015-05-25 19:11:52 +0100 | [diff] [blame] | 1853 | struct drm_property *prop_mode_id; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1854 | |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1855 | /** |
| 1856 | * @dvi_i_subconnector_property: Optional DVI-I property to |
| 1857 | * differentiate between analog or digital mode. |
| 1858 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1859 | struct drm_property *dvi_i_subconnector_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1860 | /** |
| 1861 | * @dvi_i_select_subconnector_property: Optional DVI-I property to |
| 1862 | * select between analog or digital mode. |
| 1863 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1864 | struct drm_property *dvi_i_select_subconnector_property; |
| 1865 | |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1866 | /** |
| 1867 | * @tv_subconnector_property: Optional TV property to differentiate |
| 1868 | * between different TV connector types. |
| 1869 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1870 | struct drm_property *tv_subconnector_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1871 | /** |
| 1872 | * @tv_select_subconnector_property: Optional TV property to select |
| 1873 | * between different TV connector types. |
| 1874 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1875 | struct drm_property *tv_select_subconnector_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1876 | /** |
| 1877 | * @tv_mode_property: Optional TV property to select |
| 1878 | * the output TV mode. |
| 1879 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1880 | struct drm_property *tv_mode_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1881 | /** |
| 1882 | * @tv_left_margin_property: Optional TV property to set the left |
| 1883 | * margin. |
| 1884 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1885 | struct drm_property *tv_left_margin_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1886 | /** |
| 1887 | * @tv_right_margin_property: Optional TV property to set the right |
| 1888 | * margin. |
| 1889 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1890 | struct drm_property *tv_right_margin_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1891 | /** |
| 1892 | * @tv_top_margin_property: Optional TV property to set the right |
| 1893 | * margin. |
| 1894 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1895 | struct drm_property *tv_top_margin_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1896 | /** |
| 1897 | * @tv_bottom_margin_property: Optional TV property to set the right |
| 1898 | * margin. |
| 1899 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1900 | struct drm_property *tv_bottom_margin_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1901 | /** |
| 1902 | * @tv_brightness_property: Optional TV property to set the |
| 1903 | * brightness. |
| 1904 | */ |
Francisco Jerez | b6b7902 | 2009-08-02 04:19:20 +0200 | [diff] [blame] | 1905 | struct drm_property *tv_brightness_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1906 | /** |
| 1907 | * @tv_contrast_property: Optional TV property to set the |
| 1908 | * contrast. |
| 1909 | */ |
Francisco Jerez | b6b7902 | 2009-08-02 04:19:20 +0200 | [diff] [blame] | 1910 | struct drm_property *tv_contrast_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1911 | /** |
| 1912 | * @tv_flicker_reduction_property: Optional TV property to control the |
| 1913 | * flicker reduction mode. |
| 1914 | */ |
Francisco Jerez | b6b7902 | 2009-08-02 04:19:20 +0200 | [diff] [blame] | 1915 | struct drm_property *tv_flicker_reduction_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1916 | /** |
| 1917 | * @tv_overscan_property: Optional TV property to control the overscan |
| 1918 | * setting. |
| 1919 | */ |
Francisco Jerez | a75f023 | 2009-08-12 02:30:10 +0200 | [diff] [blame] | 1920 | struct drm_property *tv_overscan_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1921 | /** |
| 1922 | * @tv_saturation_property: Optional TV property to set the |
| 1923 | * saturation. |
| 1924 | */ |
Francisco Jerez | a75f023 | 2009-08-12 02:30:10 +0200 | [diff] [blame] | 1925 | struct drm_property *tv_saturation_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1926 | /** |
| 1927 | * @tv_hue_property: Optional TV property to set the hue. |
| 1928 | */ |
Francisco Jerez | a75f023 | 2009-08-12 02:30:10 +0200 | [diff] [blame] | 1929 | struct drm_property *tv_hue_property; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1930 | |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1931 | /** |
| 1932 | * @scaling_mode_property: Optional connector property to control the |
| 1933 | * upscaling, mostly used for built-in panels. |
| 1934 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1935 | struct drm_property *scaling_mode_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1936 | /** |
| 1937 | * @aspect_ratio_property: Optional connector property to control the |
| 1938 | * HDMI infoframe aspect ratio setting. |
| 1939 | */ |
Vandana Kannan | ff587e4 | 2014-06-11 10:46:48 +0530 | [diff] [blame] | 1940 | struct drm_property *aspect_ratio_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1941 | /** |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1942 | * @degamma_lut_property: Optional CRTC property to set the LUT used to |
| 1943 | * convert the framebuffer's colors to linear gamma. |
| 1944 | */ |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 1945 | struct drm_property *degamma_lut_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1946 | /** |
| 1947 | * @degamma_lut_size_property: Optional CRTC property for the size of |
| 1948 | * the degamma LUT as supported by the driver (read-only). |
| 1949 | */ |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 1950 | struct drm_property *degamma_lut_size_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1951 | /** |
| 1952 | * @ctm_property: Optional CRTC property to set the |
| 1953 | * matrix used to convert colors after the lookup in the |
| 1954 | * degamma LUT. |
| 1955 | */ |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 1956 | struct drm_property *ctm_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1957 | /** |
| 1958 | * @gamma_lut_property: Optional CRTC property to set the LUT used to |
| 1959 | * convert the colors, after the CTM matrix, to the gamma space of the |
| 1960 | * connected screen. |
| 1961 | */ |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 1962 | struct drm_property *gamma_lut_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1963 | /** |
| 1964 | * @gamma_lut_size_property: Optional CRTC property for the size of the |
| 1965 | * gamma LUT as supported by the driver (read-only). |
| 1966 | */ |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 1967 | struct drm_property *gamma_lut_size_property; |
| 1968 | |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1969 | /** |
| 1970 | * @suggested_x_property: Optional connector property with a hint for |
| 1971 | * the position of the output on the host's screen. |
| 1972 | */ |
Dave Airlie | 5bb2bbf | 2014-11-10 10:18:15 +1000 | [diff] [blame] | 1973 | struct drm_property *suggested_x_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1974 | /** |
| 1975 | * @suggested_y_property: Optional connector property with a hint for |
| 1976 | * the position of the output on the host's screen. |
| 1977 | */ |
Dave Airlie | 5bb2bbf | 2014-11-10 10:18:15 +1000 | [diff] [blame] | 1978 | struct drm_property *suggested_y_property; |
| 1979 | |
Dave Airlie | 019d96c | 2011-09-29 16:20:42 +0100 | [diff] [blame] | 1980 | /* dumb ioctl parameters */ |
| 1981 | uint32_t preferred_depth, prefer_shadow; |
Keith Packard | 62f2104 | 2013-07-22 18:50:00 -0700 | [diff] [blame] | 1982 | |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 1983 | /** |
| 1984 | * @async_page_flip: Does this device support async flips on the primary |
| 1985 | * plane? |
| 1986 | */ |
Keith Packard | 62f2104 | 2013-07-22 18:50:00 -0700 | [diff] [blame] | 1987 | bool async_page_flip; |
Alex Deucher | 8716ed4 | 2014-02-12 12:48:23 -0500 | [diff] [blame] | 1988 | |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 1989 | /** |
| 1990 | * @allow_fb_modifiers: |
| 1991 | * |
| 1992 | * Whether the driver supports fb modifiers in the ADDFB2.1 ioctl call. |
| 1993 | */ |
Rob Clark | e3eb325 | 2015-02-05 14:41:52 +0000 | [diff] [blame] | 1994 | bool allow_fb_modifiers; |
| 1995 | |
Alex Deucher | 8716ed4 | 2014-02-12 12:48:23 -0500 | [diff] [blame] | 1996 | /* cursor size */ |
| 1997 | uint32_t cursor_width, cursor_height; |
Daniel Vetter | 9f2a795 | 2016-06-08 14:19:02 +0200 | [diff] [blame] | 1998 | |
| 1999 | struct drm_mode_config_helper_funcs *helper_private; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2000 | }; |
| 2001 | |
Rob Clark | dd27595 | 2014-11-25 20:29:46 -0500 | [diff] [blame] | 2002 | /** |
| 2003 | * drm_for_each_plane_mask - iterate over planes specified by bitmask |
| 2004 | * @plane: the loop cursor |
| 2005 | * @dev: the DRM device |
| 2006 | * @plane_mask: bitmask of plane indices |
| 2007 | * |
| 2008 | * Iterate over all planes specified by bitmask. |
| 2009 | */ |
| 2010 | #define drm_for_each_plane_mask(plane, dev, plane_mask) \ |
| 2011 | list_for_each_entry((plane), &(dev)->mode_config.plane_list, head) \ |
Jani Nikula | 373701b | 2015-11-24 21:21:55 +0200 | [diff] [blame] | 2012 | for_each_if ((plane_mask) & (1 << drm_plane_index(plane))) |
Rob Clark | dd27595 | 2014-11-25 20:29:46 -0500 | [diff] [blame] | 2013 | |
Maarten Lankhorst | ead8b66 | 2016-01-07 10:59:19 +0100 | [diff] [blame] | 2014 | /** |
| 2015 | * drm_for_each_encoder_mask - iterate over encoders specified by bitmask |
| 2016 | * @encoder: the loop cursor |
| 2017 | * @dev: the DRM device |
| 2018 | * @encoder_mask: bitmask of encoder indices |
| 2019 | * |
| 2020 | * Iterate over all encoders specified by bitmask. |
| 2021 | */ |
| 2022 | #define drm_for_each_encoder_mask(encoder, dev, encoder_mask) \ |
| 2023 | list_for_each_entry((encoder), &(dev)->mode_config.encoder_list, head) \ |
| 2024 | for_each_if ((encoder_mask) & (1 << drm_encoder_index(encoder))) |
Rob Clark | dd27595 | 2014-11-25 20:29:46 -0500 | [diff] [blame] | 2025 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2026 | #define obj_to_crtc(x) container_of(x, struct drm_crtc, base) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2027 | #define obj_to_mode(x) container_of(x, struct drm_display_mode, base) |
| 2028 | #define obj_to_fb(x) container_of(x, struct drm_framebuffer, base) |
| 2029 | #define obj_to_property(x) container_of(x, struct drm_property, base) |
| 2030 | #define obj_to_blob(x) container_of(x, struct drm_property_blob, base) |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 2031 | #define obj_to_plane(x) container_of(x, struct drm_plane, base) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2032 | |
Sascha Hauer | 4a67d39 | 2012-02-06 10:58:17 +0100 | [diff] [blame] | 2033 | struct drm_prop_enum_list { |
| 2034 | int type; |
| 2035 | char *name; |
| 2036 | }; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2037 | |
Ville Syrjälä | f988287 | 2015-12-09 16:19:31 +0200 | [diff] [blame] | 2038 | extern __printf(6, 7) |
| 2039 | int drm_crtc_init_with_planes(struct drm_device *dev, |
| 2040 | struct drm_crtc *crtc, |
| 2041 | struct drm_plane *primary, |
| 2042 | struct drm_plane *cursor, |
| 2043 | const struct drm_crtc_funcs *funcs, |
| 2044 | const char *name, ...); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2045 | extern void drm_crtc_cleanup(struct drm_crtc *crtc); |
Chris Wilson | 490d3d1 | 2016-05-27 20:05:00 +0100 | [diff] [blame] | 2046 | |
| 2047 | /** |
| 2048 | * drm_crtc_index - find the index of a registered CRTC |
| 2049 | * @crtc: CRTC to find index for |
| 2050 | * |
| 2051 | * Given a registered CRTC, return the index of that CRTC within a DRM |
| 2052 | * device's list of CRTCs. |
| 2053 | */ |
| 2054 | static inline unsigned int drm_crtc_index(struct drm_crtc *crtc) |
| 2055 | { |
| 2056 | return crtc->index; |
| 2057 | } |
Russell King | db5f7a6 | 2014-01-02 21:27:33 +0000 | [diff] [blame] | 2058 | |
| 2059 | /** |
| 2060 | * drm_crtc_mask - find the mask of a registered CRTC |
| 2061 | * @crtc: CRTC to find mask for |
| 2062 | * |
| 2063 | * Given a registered CRTC, return the mask bit of that CRTC for an |
| 2064 | * encoder's possible_crtcs field. |
| 2065 | */ |
| 2066 | static inline uint32_t drm_crtc_mask(struct drm_crtc *crtc) |
| 2067 | { |
| 2068 | return 1 << drm_crtc_index(crtc); |
| 2069 | } |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2070 | |
Ville Syrjälä | b0b3b79 | 2015-12-09 16:19:55 +0200 | [diff] [blame] | 2071 | extern __printf(8, 9) |
| 2072 | int drm_universal_plane_init(struct drm_device *dev, |
| 2073 | struct drm_plane *plane, |
| 2074 | unsigned long possible_crtcs, |
| 2075 | const struct drm_plane_funcs *funcs, |
| 2076 | const uint32_t *formats, |
| 2077 | unsigned int format_count, |
| 2078 | enum drm_plane_type type, |
| 2079 | const char *name, ...); |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 2080 | extern int drm_plane_init(struct drm_device *dev, |
| 2081 | struct drm_plane *plane, |
| 2082 | unsigned long possible_crtcs, |
| 2083 | const struct drm_plane_funcs *funcs, |
Thierry Reding | 45e3743 | 2015-08-12 16:54:28 +0200 | [diff] [blame] | 2084 | const uint32_t *formats, unsigned int format_count, |
Matt Roper | dc415ff | 2014-04-01 15:22:36 -0700 | [diff] [blame] | 2085 | bool is_primary); |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 2086 | extern void drm_plane_cleanup(struct drm_plane *plane); |
Chris Wilson | 490d3d1 | 2016-05-27 20:05:00 +0100 | [diff] [blame] | 2087 | |
| 2088 | /** |
| 2089 | * drm_plane_index - find the index of a registered plane |
| 2090 | * @plane: plane to find index for |
| 2091 | * |
| 2092 | * Given a registered plane, return the index of that plane within a DRM |
| 2093 | * device's list of planes. |
| 2094 | */ |
| 2095 | static inline unsigned int drm_plane_index(struct drm_plane *plane) |
| 2096 | { |
| 2097 | return plane->index; |
| 2098 | } |
Chandra Konduru | f81338a | 2015-04-09 17:36:21 -0700 | [diff] [blame] | 2099 | extern struct drm_plane * drm_plane_from_index(struct drm_device *dev, int idx); |
Ville Syrjälä | 9125e61 | 2013-06-03 16:10:40 +0300 | [diff] [blame] | 2100 | extern void drm_plane_force_disable(struct drm_plane *plane); |
Gustavo Padovan | ecb7e16 | 2014-12-01 15:40:09 -0800 | [diff] [blame] | 2101 | extern void drm_crtc_get_hv_timing(const struct drm_display_mode *mode, |
| 2102 | int *hdisplay, int *vdisplay); |
Lukas Wunner | 6a0d952 | 2016-06-08 18:47:27 +0200 | [diff] [blame] | 2103 | extern int drm_crtc_force_disable(struct drm_crtc *crtc); |
| 2104 | extern int drm_crtc_force_disable_all(struct drm_device *dev); |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 2105 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2106 | extern void drm_mode_config_init(struct drm_device *dev); |
Chris Wilson | eb03355 | 2011-01-24 15:11:08 +0000 | [diff] [blame] | 2107 | extern void drm_mode_config_reset(struct drm_device *dev); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2108 | extern void drm_mode_config_cleanup(struct drm_device *dev); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2109 | |
Rob Clark | 5ea22f2 | 2014-05-30 11:34:01 -0400 | [diff] [blame] | 2110 | static inline bool drm_property_type_is(struct drm_property *property, |
| 2111 | uint32_t type) |
| 2112 | { |
| 2113 | /* instanceof for props.. handles extended type vs original types: */ |
| 2114 | if (property->flags & DRM_MODE_PROP_EXTENDED_TYPE) |
| 2115 | return (property->flags & DRM_MODE_PROP_EXTENDED_TYPE) == type; |
| 2116 | return property->flags & type; |
| 2117 | } |
| 2118 | |
Paulo Zanoni | c543188 | 2012-05-15 18:09:02 -0300 | [diff] [blame] | 2119 | extern int drm_object_property_set_value(struct drm_mode_object *obj, |
| 2120 | struct drm_property *property, |
| 2121 | uint64_t val); |
| 2122 | extern int drm_object_property_get_value(struct drm_mode_object *obj, |
| 2123 | struct drm_property *property, |
| 2124 | uint64_t *value); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2125 | |
Paulo Zanoni | c543188 | 2012-05-15 18:09:02 -0300 | [diff] [blame] | 2126 | extern void drm_object_attach_property(struct drm_mode_object *obj, |
| 2127 | struct drm_property *property, |
| 2128 | uint64_t init_val); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2129 | extern struct drm_property *drm_property_create(struct drm_device *dev, int flags, |
| 2130 | const char *name, int num_values); |
Sascha Hauer | 4a67d39 | 2012-02-06 10:58:17 +0100 | [diff] [blame] | 2131 | extern struct drm_property *drm_property_create_enum(struct drm_device *dev, int flags, |
| 2132 | const char *name, |
| 2133 | const struct drm_prop_enum_list *props, |
| 2134 | int num_values); |
Rob Clark | 49e2754 | 2012-05-17 02:23:26 -0600 | [diff] [blame] | 2135 | struct drm_property *drm_property_create_bitmask(struct drm_device *dev, |
| 2136 | int flags, const char *name, |
| 2137 | const struct drm_prop_enum_list *props, |
Ville Syrjälä | 7689ffb | 2014-07-08 10:31:52 +0530 | [diff] [blame] | 2138 | int num_props, |
| 2139 | uint64_t supported_bits); |
Sascha Hauer | d9bc3c0 | 2012-02-06 10:58:18 +0100 | [diff] [blame] | 2140 | struct drm_property *drm_property_create_range(struct drm_device *dev, int flags, |
| 2141 | const char *name, |
| 2142 | uint64_t min, uint64_t max); |
Rob Clark | ebc44cf | 2012-09-12 22:22:31 -0500 | [diff] [blame] | 2143 | struct drm_property *drm_property_create_signed_range(struct drm_device *dev, |
| 2144 | int flags, const char *name, |
| 2145 | int64_t min, int64_t max); |
Rob Clark | 98f75de | 2014-05-30 11:37:03 -0400 | [diff] [blame] | 2146 | struct drm_property *drm_property_create_object(struct drm_device *dev, |
| 2147 | int flags, const char *name, uint32_t type); |
Daniel Vetter | 960cd9d | 2015-01-21 08:47:38 +0100 | [diff] [blame] | 2148 | struct drm_property *drm_property_create_bool(struct drm_device *dev, int flags, |
| 2149 | const char *name); |
Daniel Stone | 6bcacf5 | 2015-04-20 19:22:55 +0100 | [diff] [blame] | 2150 | struct drm_property_blob *drm_property_create_blob(struct drm_device *dev, |
| 2151 | size_t length, |
| 2152 | const void *data); |
| 2153 | struct drm_property_blob *drm_property_lookup_blob(struct drm_device *dev, |
| 2154 | uint32_t id); |
Daniel Vetter | adebd6f | 2016-08-12 22:48:49 +0200 | [diff] [blame] | 2155 | int drm_property_replace_global_blob(struct drm_device *dev, |
| 2156 | struct drm_property_blob **replace, |
| 2157 | size_t length, |
| 2158 | const void *data, |
| 2159 | struct drm_mode_object *obj_holds_id, |
| 2160 | struct drm_property *prop_holds_id); |
Daniel Stone | 6bcacf5 | 2015-04-20 19:22:55 +0100 | [diff] [blame] | 2161 | struct drm_property_blob *drm_property_reference_blob(struct drm_property_blob *blob); |
| 2162 | void drm_property_unreference_blob(struct drm_property_blob *blob); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2163 | extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property); |
| 2164 | extern int drm_property_add_enum(struct drm_property *property, int index, |
| 2165 | uint64_t value, const char *name); |
Sascha Hauer | 4cae5b8 | 2012-02-01 11:38:23 +0100 | [diff] [blame] | 2166 | extern int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2167 | int gamma_size); |
Rob Clark | 98f75de | 2014-05-30 11:37:03 -0400 | [diff] [blame] | 2168 | |
Daniel Vetter | 2d13b67 | 2012-12-11 13:47:23 +0100 | [diff] [blame] | 2169 | extern int drm_mode_set_config_internal(struct drm_mode_set *set); |
Daniel Vetter | 8106554 | 2016-06-21 10:54:13 +0200 | [diff] [blame] | 2170 | |
Jesse Barnes | 308e5bc | 2011-11-14 14:51:28 -0800 | [diff] [blame] | 2171 | extern uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth); |
Dave Airlie | 138f9eb | 2014-10-20 16:17:17 +1000 | [diff] [blame] | 2172 | |
| 2173 | extern struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev, |
| 2174 | char topology[8]); |
| 2175 | extern struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev, |
| 2176 | char topology[8]); |
| 2177 | extern void drm_mode_put_tile_group(struct drm_device *dev, |
| 2178 | struct drm_tile_group *tg); |
Dave Airlie | ff72145b | 2011-02-07 12:16:14 +1000 | [diff] [blame] | 2179 | |
Thomas Wood | 3a5f87c | 2014-08-20 14:45:00 +0100 | [diff] [blame] | 2180 | extern int drm_mode_plane_set_obj_prop(struct drm_plane *plane, |
| 2181 | struct drm_property *property, |
| 2182 | uint64_t value); |
Dave Airlie | 248dbc2 | 2011-11-29 20:02:54 +0000 | [diff] [blame] | 2183 | |
Ville Syrjälä | c1df5f3 | 2014-07-08 10:31:53 +0530 | [diff] [blame] | 2184 | extern struct drm_property *drm_mode_create_rotation_property(struct drm_device *dev, |
| 2185 | unsigned int supported_rotations); |
Ville Syrjälä | 3c9855f | 2014-07-08 10:31:56 +0530 | [diff] [blame] | 2186 | extern unsigned int drm_rotation_simplify(unsigned int rotation, |
| 2187 | unsigned int supported_rotations); |
Jyri Sarha | f8ed34a | 2016-06-07 15:09:14 +0300 | [diff] [blame] | 2188 | extern void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, |
| 2189 | uint degamma_lut_size, |
| 2190 | bool has_ctm, |
| 2191 | uint gamma_lut_size); |
Marek Szyprowski | 44d1240d | 2016-06-13 11:11:26 +0200 | [diff] [blame] | 2192 | |
| 2193 | int drm_plane_create_zpos_property(struct drm_plane *plane, |
| 2194 | unsigned int zpos, |
| 2195 | unsigned int min, unsigned int max); |
| 2196 | |
| 2197 | int drm_plane_create_zpos_immutable_property(struct drm_plane *plane, |
| 2198 | unsigned int zpos); |
| 2199 | |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 2200 | /* Helpers */ |
Rob Clark | a2b34e2 | 2013-10-05 16:36:52 -0400 | [diff] [blame] | 2201 | static inline struct drm_plane *drm_plane_find(struct drm_device *dev, |
| 2202 | uint32_t id) |
| 2203 | { |
| 2204 | struct drm_mode_object *mo; |
| 2205 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_PLANE); |
| 2206 | return mo ? obj_to_plane(mo) : NULL; |
| 2207 | } |
| 2208 | |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 2209 | static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev, |
| 2210 | uint32_t id) |
| 2211 | { |
| 2212 | struct drm_mode_object *mo; |
| 2213 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CRTC); |
| 2214 | return mo ? obj_to_crtc(mo) : NULL; |
| 2215 | } |
| 2216 | |
Rob Clark | a2b34e2 | 2013-10-05 16:36:52 -0400 | [diff] [blame] | 2217 | static inline struct drm_property *drm_property_find(struct drm_device *dev, |
| 2218 | uint32_t id) |
| 2219 | { |
| 2220 | struct drm_mode_object *mo; |
| 2221 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_PROPERTY); |
| 2222 | return mo ? obj_to_property(mo) : NULL; |
| 2223 | } |
| 2224 | |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 2225 | /* |
| 2226 | * Extract a degamma/gamma LUT value provided by user and round it to the |
| 2227 | * precision supported by the hardware. |
| 2228 | */ |
| 2229 | static inline uint32_t drm_color_lut_extract(uint32_t user_input, |
| 2230 | uint32_t bit_precision) |
| 2231 | { |
Lionel Landwerlin | 644a805 | 2016-03-22 14:10:33 +0000 | [diff] [blame] | 2232 | uint32_t val = user_input; |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 2233 | uint32_t max = 0xffff >> (16 - bit_precision); |
| 2234 | |
Lionel Landwerlin | 644a805 | 2016-03-22 14:10:33 +0000 | [diff] [blame] | 2235 | /* Round only if we're not using full precision. */ |
| 2236 | if (bit_precision < 16) { |
| 2237 | val += 1UL << (16 - bit_precision - 1); |
| 2238 | val >>= 16 - bit_precision; |
| 2239 | } |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 2240 | |
| 2241 | return clamp_val(val, 0, max); |
| 2242 | } |
| 2243 | |
Matt Roper | e27dde3 | 2014-04-01 15:22:30 -0700 | [diff] [blame] | 2244 | /* Plane list iterator for legacy (overlay only) planes. */ |
Daniel Vetter | 4ea50e9 | 2015-07-09 23:44:24 +0200 | [diff] [blame] | 2245 | #define drm_for_each_legacy_plane(plane, dev) \ |
| 2246 | list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) \ |
Jani Nikula | 373701b | 2015-11-24 21:21:55 +0200 | [diff] [blame] | 2247 | for_each_if (plane->type == DRM_PLANE_TYPE_OVERLAY) |
Matt Roper | e27dde3 | 2014-04-01 15:22:30 -0700 | [diff] [blame] | 2248 | |
Daniel Vetter | 6295d60 | 2015-07-09 23:44:25 +0200 | [diff] [blame] | 2249 | #define drm_for_each_plane(plane, dev) \ |
| 2250 | list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) |
| 2251 | |
| 2252 | #define drm_for_each_crtc(crtc, dev) \ |
| 2253 | list_for_each_entry(crtc, &(dev)->mode_config.crtc_list, head) |
| 2254 | |
Daniel Vetter | 7a3f3d6 | 2015-07-09 23:44:28 +0200 | [diff] [blame] | 2255 | static inline void |
| 2256 | assert_drm_connector_list_read_locked(struct drm_mode_config *mode_config) |
| 2257 | { |
Daniel Vetter | cff20ba | 2015-07-09 23:44:33 +0200 | [diff] [blame] | 2258 | /* |
| 2259 | * The connector hotadd/remove code currently grabs both locks when |
| 2260 | * updating lists. Hence readers need only hold either of them to be |
| 2261 | * safe and the check amounts to |
| 2262 | * |
| 2263 | * WARN_ON(not_holding(A) && not_holding(B)). |
| 2264 | */ |
| 2265 | WARN_ON(!mutex_is_locked(&mode_config->mutex) && |
| 2266 | !drm_modeset_is_locked(&mode_config->connection_mutex)); |
Daniel Vetter | 7a3f3d6 | 2015-07-09 23:44:28 +0200 | [diff] [blame] | 2267 | } |
| 2268 | |
Daniel Vetter | 6295d60 | 2015-07-09 23:44:25 +0200 | [diff] [blame] | 2269 | #define drm_for_each_connector(connector, dev) \ |
Daniel Vetter | 7a3f3d6 | 2015-07-09 23:44:28 +0200 | [diff] [blame] | 2270 | for (assert_drm_connector_list_read_locked(&(dev)->mode_config), \ |
| 2271 | connector = list_first_entry(&(dev)->mode_config.connector_list, \ |
| 2272 | struct drm_connector, head); \ |
| 2273 | &connector->head != (&(dev)->mode_config.connector_list); \ |
| 2274 | connector = list_next_entry(connector, head)) |
Daniel Vetter | 6295d60 | 2015-07-09 23:44:25 +0200 | [diff] [blame] | 2275 | |
| 2276 | #define drm_for_each_encoder(encoder, dev) \ |
| 2277 | list_for_each_entry(encoder, &(dev)->mode_config.encoder_list, head) |
| 2278 | |
| 2279 | #define drm_for_each_fb(fb, dev) \ |
Daniel Vetter | 4676ba0 | 2015-07-09 23:44:30 +0200 | [diff] [blame] | 2280 | for (WARN_ON(!mutex_is_locked(&(dev)->mode_config.fb_lock)), \ |
| 2281 | fb = list_first_entry(&(dev)->mode_config.fb_list, \ |
| 2282 | struct drm_framebuffer, head); \ |
| 2283 | &fb->head != (&(dev)->mode_config.fb_list); \ |
| 2284 | fb = list_next_entry(fb, head)) |
Daniel Vetter | 6295d60 | 2015-07-09 23:44:25 +0200 | [diff] [blame] | 2285 | |
Daniel Vetter | 8106554 | 2016-06-21 10:54:13 +0200 | [diff] [blame] | 2286 | /* drm_edid.c */ |
| 2287 | bool drm_probe_ddc(struct i2c_adapter *adapter); |
| 2288 | struct edid *drm_get_edid(struct drm_connector *connector, |
| 2289 | struct i2c_adapter *adapter); |
| 2290 | struct edid *drm_get_edid_switcheroo(struct drm_connector *connector, |
| 2291 | struct i2c_adapter *adapter); |
| 2292 | struct edid *drm_edid_duplicate(const struct edid *edid); |
| 2293 | int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid); |
| 2294 | |
| 2295 | u8 drm_match_cea_mode(const struct drm_display_mode *to_match); |
| 2296 | enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code); |
| 2297 | bool drm_detect_hdmi_monitor(struct edid *edid); |
| 2298 | bool drm_detect_monitor_audio(struct edid *edid); |
| 2299 | bool drm_rgb_quant_range_selectable(struct edid *edid); |
| 2300 | int drm_add_modes_noedid(struct drm_connector *connector, |
| 2301 | int hdisplay, int vdisplay); |
| 2302 | void drm_set_preferred_mode(struct drm_connector *connector, |
| 2303 | int hpref, int vpref); |
| 2304 | |
| 2305 | int drm_edid_header_is_valid(const u8 *raw_edid); |
| 2306 | bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid, |
| 2307 | bool *edid_corrupt); |
| 2308 | bool drm_edid_is_valid(struct edid *edid); |
| 2309 | void drm_edid_get_monitor_name(struct edid *edid, char *name, |
| 2310 | int buflen); |
| 2311 | struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev, |
| 2312 | int hsize, int vsize, int fresh, |
| 2313 | bool rb); |
| 2314 | |
| 2315 | /* drm_bridge.c */ |
| 2316 | extern int drm_bridge_add(struct drm_bridge *bridge); |
| 2317 | extern void drm_bridge_remove(struct drm_bridge *bridge); |
| 2318 | extern struct drm_bridge *of_drm_find_bridge(struct device_node *np); |
| 2319 | extern int drm_bridge_attach(struct drm_device *dev, struct drm_bridge *bridge); |
Andrea Merello | cf3bef9 | 2016-08-25 11:04:32 +0200 | [diff] [blame] | 2320 | extern void drm_bridge_detach(struct drm_bridge *bridge); |
Daniel Vetter | 8106554 | 2016-06-21 10:54:13 +0200 | [diff] [blame] | 2321 | |
| 2322 | bool drm_bridge_mode_fixup(struct drm_bridge *bridge, |
| 2323 | const struct drm_display_mode *mode, |
| 2324 | struct drm_display_mode *adjusted_mode); |
| 2325 | void drm_bridge_disable(struct drm_bridge *bridge); |
| 2326 | void drm_bridge_post_disable(struct drm_bridge *bridge); |
| 2327 | void drm_bridge_mode_set(struct drm_bridge *bridge, |
| 2328 | struct drm_display_mode *mode, |
| 2329 | struct drm_display_mode *adjusted_mode); |
| 2330 | void drm_bridge_pre_enable(struct drm_bridge *bridge); |
| 2331 | void drm_bridge_enable(struct drm_bridge *bridge); |
| 2332 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2333 | #endif /* __DRM_CRTC_H__ */ |