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