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> |
Jesse Barnes | 308e5bc | 2011-11-14 14:51:28 -0800 | [diff] [blame] | 38 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 39 | struct drm_device; |
| 40 | struct drm_mode_set; |
| 41 | struct drm_framebuffer; |
Paulo Zanoni | 7e3bdf4 | 2012-05-15 18:09:01 -0300 | [diff] [blame] | 42 | struct drm_object_properties; |
Thierry Reding | 595887e | 2012-11-21 15:00:47 +0100 | [diff] [blame] | 43 | struct drm_file; |
| 44 | struct drm_clip_rect; |
Russell King | 7e435aa | 2014-06-15 11:07:12 +0100 | [diff] [blame] | 45 | struct device_node; |
Daniel Vetter | e2330f0 | 2014-10-29 11:34:56 +0100 | [diff] [blame] | 46 | struct fence; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 47 | |
| 48 | #define DRM_MODE_OBJECT_CRTC 0xcccccccc |
| 49 | #define DRM_MODE_OBJECT_CONNECTOR 0xc0c0c0c0 |
| 50 | #define DRM_MODE_OBJECT_ENCODER 0xe0e0e0e0 |
| 51 | #define DRM_MODE_OBJECT_MODE 0xdededede |
| 52 | #define DRM_MODE_OBJECT_PROPERTY 0xb0b0b0b0 |
| 53 | #define DRM_MODE_OBJECT_FB 0xfbfbfbfb |
| 54 | #define DRM_MODE_OBJECT_BLOB 0xbbbbbbbb |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 55 | #define DRM_MODE_OBJECT_PLANE 0xeeeeeeee |
Rob Clark | 98f75de | 2014-05-30 11:37:03 -0400 | [diff] [blame] | 56 | #define DRM_MODE_OBJECT_ANY 0 |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 57 | |
| 58 | struct drm_mode_object { |
| 59 | uint32_t id; |
| 60 | uint32_t type; |
Paulo Zanoni | 7e3bdf4 | 2012-05-15 18:09:01 -0300 | [diff] [blame] | 61 | struct drm_object_properties *properties; |
| 62 | }; |
| 63 | |
Paulo Zanoni | fe45616 | 2012-06-12 11:27:01 -0300 | [diff] [blame] | 64 | #define DRM_OBJECT_MAX_PROPERTY 24 |
Paulo Zanoni | 7e3bdf4 | 2012-05-15 18:09:01 -0300 | [diff] [blame] | 65 | struct drm_object_properties { |
Rob Clark | 88a48e2 | 2014-12-18 16:01:50 -0500 | [diff] [blame] | 66 | int count, atomic_count; |
Rob Clark | b17cd75 | 2014-12-16 18:05:30 -0500 | [diff] [blame] | 67 | /* NOTE: if we ever start dynamically destroying properties (ie. |
| 68 | * not at drm_mode_config_cleanup() time), then we'd have to do |
| 69 | * a better job of detaching property from mode objects to avoid |
| 70 | * dangling property pointers: |
| 71 | */ |
| 72 | struct drm_property *properties[DRM_OBJECT_MAX_PROPERTY]; |
Rob Clark | 22b8b13 | 2014-12-16 18:05:31 -0500 | [diff] [blame] | 73 | /* do not read/write values directly, but use drm_object_property_get_value() |
| 74 | * and drm_object_property_set_value(): |
| 75 | */ |
Paulo Zanoni | 7e3bdf4 | 2012-05-15 18:09:01 -0300 | [diff] [blame] | 76 | uint64_t values[DRM_OBJECT_MAX_PROPERTY]; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 77 | }; |
| 78 | |
Rob Clark | ebc44cf | 2012-09-12 22:22:31 -0500 | [diff] [blame] | 79 | static inline int64_t U642I64(uint64_t val) |
| 80 | { |
| 81 | return (int64_t)*((int64_t *)&val); |
| 82 | } |
| 83 | static inline uint64_t I642U64(int64_t val) |
| 84 | { |
| 85 | return (uint64_t)*((uint64_t *)&val); |
| 86 | } |
| 87 | |
Robert Fekete | d9c3824 | 2015-11-02 16:14:08 +0100 | [diff] [blame] | 88 | /* |
| 89 | * Rotation property bits. DRM_ROTATE_<degrees> rotates the image by the |
| 90 | * specified amount in degrees in counter clockwise direction. DRM_REFLECT_X and |
| 91 | * DRM_REFLECT_Y reflects the image along the specified axis prior to rotation |
| 92 | */ |
Joonas Lahtinen | 6220907 | 2015-10-01 10:00:57 +0300 | [diff] [blame] | 93 | #define DRM_ROTATE_MASK 0x0f |
Ville Syrjälä | 0659696 | 2014-07-08 10:31:51 +0530 | [diff] [blame] | 94 | #define DRM_ROTATE_0 0 |
| 95 | #define DRM_ROTATE_90 1 |
| 96 | #define DRM_ROTATE_180 2 |
| 97 | #define DRM_ROTATE_270 3 |
Joonas Lahtinen | 6220907 | 2015-10-01 10:00:57 +0300 | [diff] [blame] | 98 | #define DRM_REFLECT_MASK (~DRM_ROTATE_MASK) |
Ville Syrjälä | 0659696 | 2014-07-08 10:31:51 +0530 | [diff] [blame] | 99 | #define DRM_REFLECT_X 4 |
| 100 | #define DRM_REFLECT_Y 5 |
| 101 | |
Daniel Vetter | 5531000 | 2014-01-23 15:52:20 +0100 | [diff] [blame] | 102 | enum drm_connector_force { |
| 103 | DRM_FORCE_UNSPECIFIED, |
| 104 | DRM_FORCE_OFF, |
| 105 | DRM_FORCE_ON, /* force on analog part normally */ |
| 106 | DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 107 | }; |
| 108 | |
Daniel Vetter | 5531000 | 2014-01-23 15:52:20 +0100 | [diff] [blame] | 109 | #include <drm/drm_modes.h> |
Damien Lespiau | 4aa17cf | 2013-09-25 16:45:21 +0100 | [diff] [blame] | 110 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 111 | enum drm_connector_status { |
| 112 | connector_status_connected = 1, |
| 113 | connector_status_disconnected = 2, |
| 114 | connector_status_unknown = 3, |
| 115 | }; |
| 116 | |
| 117 | enum subpixel_order { |
| 118 | SubPixelUnknown = 0, |
| 119 | SubPixelHorizontalRGB, |
| 120 | SubPixelHorizontalBGR, |
| 121 | SubPixelVerticalRGB, |
| 122 | SubPixelVerticalBGR, |
| 123 | SubPixelNone, |
| 124 | }; |
| 125 | |
Jesse Barnes | da05a5a7 | 2011-04-15 13:48:57 -0700 | [diff] [blame] | 126 | #define DRM_COLOR_FORMAT_RGB444 (1<<0) |
| 127 | #define DRM_COLOR_FORMAT_YCRCB444 (1<<1) |
| 128 | #define DRM_COLOR_FORMAT_YCRCB422 (1<<2) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 129 | /* |
| 130 | * Describes a given display (e.g. CRT or flat panel) and its limitations. |
| 131 | */ |
| 132 | struct drm_display_info { |
| 133 | char name[DRM_DISPLAY_INFO_LEN]; |
Adam Jackson | fb43964 | 2010-08-03 14:38:16 -0400 | [diff] [blame] | 134 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 135 | /* Physical size */ |
| 136 | unsigned int width_mm; |
| 137 | unsigned int height_mm; |
| 138 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 139 | /* Clock limits FIXME: storage format */ |
| 140 | unsigned int min_vfreq, max_vfreq; |
| 141 | unsigned int min_hfreq, max_hfreq; |
| 142 | unsigned int pixel_clock; |
Jesse Barnes | 3b11228 | 2011-04-15 12:49:23 -0700 | [diff] [blame] | 143 | unsigned int bpc; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 144 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 145 | enum subpixel_order subpixel_order; |
Jesse Barnes | da05a5a7 | 2011-04-15 13:48:57 -0700 | [diff] [blame] | 146 | u32 color_formats; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 147 | |
Boris Brezillon | b5571e9 | 2014-07-22 12:09:10 +0200 | [diff] [blame] | 148 | const u32 *bus_formats; |
| 149 | unsigned int num_bus_formats; |
| 150 | |
Mario Kleiner | 5d02626d | 2014-06-05 09:52:10 -0400 | [diff] [blame] | 151 | /* Mask of supported hdmi deep color modes */ |
| 152 | u8 edid_hdmi_dc_modes; |
| 153 | |
Jesse Barnes | ebec9a7b | 2011-08-03 09:22:54 -0700 | [diff] [blame] | 154 | u8 cea_rev; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 155 | }; |
| 156 | |
Dave Airlie | 138f9eb | 2014-10-20 16:17:17 +1000 | [diff] [blame] | 157 | /* data corresponds to displayid vend/prod/serial */ |
| 158 | struct drm_tile_group { |
| 159 | struct kref refcount; |
| 160 | struct drm_device *dev; |
| 161 | int id; |
| 162 | u8 group_data[8]; |
| 163 | }; |
| 164 | |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 165 | /** |
| 166 | * struct drm_framebuffer_funcs - framebuffer hooks |
| 167 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 168 | struct drm_framebuffer_funcs { |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 169 | /** |
| 170 | * @destroy: |
| 171 | * |
| 172 | * Clean up framebuffer resources, specifically also unreference the |
| 173 | * backing storage. The core guarantees to call this function for every |
| 174 | * framebuffer successfully created by ->fb_create() in |
Daniel Vetter | d55f532 | 2015-12-08 09:49:19 +0100 | [diff] [blame] | 175 | * &drm_mode_config_funcs. Drivers must also call |
| 176 | * drm_framebuffer_cleanup() to release DRM core resources for this |
| 177 | * framebuffer. |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 178 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 179 | void (*destroy)(struct drm_framebuffer *framebuffer); |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 180 | |
| 181 | /** |
| 182 | * @create_handle: |
| 183 | * |
| 184 | * Create a buffer handle in the driver-specific buffer manager (either |
| 185 | * GEM or TTM) valid for the passed-in struct &drm_file. This is used by |
| 186 | * the core to implement the GETFB IOCTL, which returns (for |
| 187 | * sufficiently priviledged user) also a native buffer handle. This can |
| 188 | * be used for seamless transitions between modesetting clients by |
| 189 | * copying the current screen contents to a private buffer and blending |
| 190 | * between that and the new contents. |
| 191 | * |
Daniel Vetter | d55f532 | 2015-12-08 09:49:19 +0100 | [diff] [blame] | 192 | * GEM based drivers should call drm_gem_handle_create() to create the |
| 193 | * handle. |
| 194 | * |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 195 | * RETURNS: |
| 196 | * |
| 197 | * 0 on success or a negative error code on failure. |
| 198 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 199 | int (*create_handle)(struct drm_framebuffer *fb, |
| 200 | struct drm_file *file_priv, |
| 201 | unsigned int *handle); |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 202 | /** |
| 203 | * @dirty: |
Jakob Bornecrantz | 884840a | 2009-12-03 23:25:47 +0000 | [diff] [blame] | 204 | * |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 205 | * Optional callback for the dirty fb IOCTL. |
Jakob Bornecrantz | 884840a | 2009-12-03 23:25:47 +0000 | [diff] [blame] | 206 | * |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 207 | * Userspace can notify the driver via this callback that an area of the |
| 208 | * framebuffer has changed and should be flushed to the display |
| 209 | * hardware. This can also be used internally, e.g. by the fbdev |
| 210 | * emulation, though that's not the case currently. |
| 211 | * |
| 212 | * See documentation in drm_mode.h for the struct drm_mode_fb_dirty_cmd |
| 213 | * for more information as all the semantics and arguments have a one to |
| 214 | * one mapping on this function. |
| 215 | * |
| 216 | * RETURNS: |
| 217 | * |
| 218 | * 0 on success or a negative error code on failure. |
Jakob Bornecrantz | 884840a | 2009-12-03 23:25:47 +0000 | [diff] [blame] | 219 | */ |
Thomas Hellstrom | 02b0016 | 2010-10-05 12:43:02 +0200 | [diff] [blame] | 220 | int (*dirty)(struct drm_framebuffer *framebuffer, |
| 221 | struct drm_file *file_priv, unsigned flags, |
Jakob Bornecrantz | 884840a | 2009-12-03 23:25:47 +0000 | [diff] [blame] | 222 | unsigned color, struct drm_clip_rect *clips, |
| 223 | unsigned num_clips); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 224 | }; |
| 225 | |
| 226 | struct drm_framebuffer { |
| 227 | struct drm_device *dev; |
Rob Clark | f7eff60 | 2012-09-05 21:48:38 +0000 | [diff] [blame] | 228 | /* |
| 229 | * Note that the fb is refcounted for the benefit of driver internals, |
| 230 | * for example some hw, disabling a CRTC/plane is asynchronous, and |
| 231 | * scanout does not actually complete until the next vblank. So some |
| 232 | * cleanup (like releasing the reference(s) on the backing GEM bo(s)) |
| 233 | * should be deferred. In cases like this, the driver would like to |
| 234 | * hold a ref to the fb even though it has already been removed from |
| 235 | * userspace perspective. |
| 236 | */ |
| 237 | struct kref refcount; |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 238 | /* |
| 239 | * Place on the dev->mode_config.fb_list, access protected by |
| 240 | * dev->mode_config.fb_lock. |
| 241 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 242 | struct list_head head; |
| 243 | struct drm_mode_object base; |
| 244 | const struct drm_framebuffer_funcs *funcs; |
Ville Syrjälä | 01f2c77 | 2011-12-20 00:06:49 +0200 | [diff] [blame] | 245 | unsigned int pitches[4]; |
| 246 | unsigned int offsets[4]; |
Rob Clark | e3eb325 | 2015-02-05 14:41:52 +0000 | [diff] [blame] | 247 | uint64_t modifier[4]; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 248 | unsigned int width; |
| 249 | unsigned int height; |
| 250 | /* depth can be 15 or 16 */ |
| 251 | unsigned int depth; |
| 252 | int bits_per_pixel; |
| 253 | int flags; |
Jesse Barnes | 308e5bc | 2011-11-14 14:51:28 -0800 | [diff] [blame] | 254 | uint32_t pixel_format; /* fourcc format */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 255 | struct list_head filp_head; |
| 256 | }; |
| 257 | |
| 258 | struct drm_property_blob { |
| 259 | struct drm_mode_object base; |
Daniel Stone | 6bcacf5 | 2015-04-20 19:22:55 +0100 | [diff] [blame] | 260 | struct drm_device *dev; |
| 261 | struct kref refcount; |
Daniel Stone | e2f5d2e | 2015-05-22 13:34:51 +0100 | [diff] [blame] | 262 | struct list_head head_global; |
| 263 | struct list_head head_file; |
Thierry Reding | ecbbe59 | 2014-05-13 11:36:13 +0200 | [diff] [blame] | 264 | size_t length; |
Ville Syrjälä | d63f5e6 | 2012-03-13 12:35:49 +0200 | [diff] [blame] | 265 | unsigned char data[]; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 266 | }; |
| 267 | |
| 268 | struct drm_property_enum { |
| 269 | uint64_t value; |
| 270 | struct list_head head; |
| 271 | char name[DRM_PROP_NAME_LEN]; |
| 272 | }; |
| 273 | |
| 274 | struct drm_property { |
| 275 | struct list_head head; |
| 276 | struct drm_mode_object base; |
| 277 | uint32_t flags; |
| 278 | char name[DRM_PROP_NAME_LEN]; |
| 279 | uint32_t num_values; |
| 280 | uint64_t *values; |
Rob Clark | 98f75de | 2014-05-30 11:37:03 -0400 | [diff] [blame] | 281 | struct drm_device *dev; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 282 | |
Daniel Vetter | 3758b34 | 2014-11-19 18:38:10 +0100 | [diff] [blame] | 283 | struct list_head enum_list; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 284 | }; |
| 285 | |
| 286 | struct drm_crtc; |
| 287 | struct drm_connector; |
| 288 | struct drm_encoder; |
Kristian Høgsberg | d91d8a3 | 2009-11-17 12:43:55 -0500 | [diff] [blame] | 289 | struct drm_pending_vblank_event; |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 290 | struct drm_plane; |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 291 | struct drm_bridge; |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 292 | struct drm_atomic_state; |
| 293 | |
Daniel Vetter | 4490d4c | 2015-12-04 09:45:45 +0100 | [diff] [blame] | 294 | struct drm_crtc_helper_funcs; |
| 295 | struct drm_encoder_helper_funcs; |
| 296 | struct drm_connector_helper_funcs; |
| 297 | struct drm_plane_helper_funcs; |
| 298 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 299 | /** |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 300 | * struct drm_crtc_state - mutable CRTC state |
Daniel Vetter | 07cc0ef | 2014-11-27 15:49:39 +0100 | [diff] [blame] | 301 | * @crtc: backpointer to the CRTC |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 302 | * @enable: whether the CRTC should be enabled, gates all other state |
Daniel Vetter | d9b1362 | 2014-11-26 16:57:41 +0100 | [diff] [blame] | 303 | * @active: whether the CRTC is actively displaying (used for DPMS) |
Maarten Lankhorst | fc59666 | 2015-07-21 13:28:57 +0200 | [diff] [blame] | 304 | * @planes_changed: planes on this crtc are updated |
| 305 | * @mode_changed: crtc_state->mode or crtc_state->enable has been changed |
| 306 | * @active_changed: crtc_state->active has been toggled. |
| 307 | * @connectors_changed: connectors to this crtc have been updated |
Rob Clark | 6ddd388 | 2014-11-21 15:28:31 -0500 | [diff] [blame] | 308 | * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes |
Maarten Lankhorst | 4cd9fa5 | 2016-01-04 12:53:18 +0100 | [diff] [blame] | 309 | * @connector_mask: bitmask of (1 << drm_connector_index(connector)) of attached connectors |
Maarten Lankhorst | e87a52b | 2016-01-28 15:04:58 +0100 | [diff] [blame] | 310 | * @encoder_mask: bitmask of (1 << drm_encoder_index(encoder)) of attached encoders |
Daniel Vetter | 623369e | 2014-09-16 17:50:47 +0200 | [diff] [blame] | 311 | * @last_vblank_count: for helpers and drivers to capture the vblank of the |
| 312 | * update to ensure framebuffer cleanup isn't done too early |
Daniel Vetter | 2f324b4 | 2014-10-29 11:13:47 +0100 | [diff] [blame] | 313 | * @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] | 314 | * @mode: current mode timings |
| 315 | * @event: optional pointer to a DRM event to signal upon completion of the |
| 316 | * state update |
| 317 | * @state: backpointer to global drm_atomic_state |
Daniel Vetter | d9b1362 | 2014-11-26 16:57:41 +0100 | [diff] [blame] | 318 | * |
| 319 | * Note that the distinction between @enable and @active is rather subtile: |
| 320 | * Flipping @active while @enable is set without changing anything else may |
| 321 | * never return in a failure from the ->atomic_check callback. Userspace assumes |
| 322 | * that a DPMS On will always succeed. In other words: @enable controls resource |
| 323 | * assignment, @active controls the actual hardware state. |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 324 | */ |
| 325 | struct drm_crtc_state { |
Daniel Vetter | 07cc0ef | 2014-11-27 15:49:39 +0100 | [diff] [blame] | 326 | struct drm_crtc *crtc; |
| 327 | |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 328 | bool enable; |
Daniel Vetter | d9b1362 | 2014-11-26 16:57:41 +0100 | [diff] [blame] | 329 | bool active; |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 330 | |
Daniel Vetter | c2fcd27 | 2014-11-05 00:14:14 +0100 | [diff] [blame] | 331 | /* computed state bits used by helpers and drivers */ |
| 332 | bool planes_changed : 1; |
Daniel Vetter | 623369e | 2014-09-16 17:50:47 +0200 | [diff] [blame] | 333 | bool mode_changed : 1; |
Daniel Vetter | eab3bbe | 2015-01-22 16:36:21 +0100 | [diff] [blame] | 334 | bool active_changed : 1; |
Maarten Lankhorst | fc59666 | 2015-07-21 13:28:57 +0200 | [diff] [blame] | 335 | bool connectors_changed : 1; |
Daniel Vetter | 623369e | 2014-09-16 17:50:47 +0200 | [diff] [blame] | 336 | |
Rob Clark | 6ddd388 | 2014-11-21 15:28:31 -0500 | [diff] [blame] | 337 | /* attached planes bitmask: |
| 338 | * WARNING: transitional helpers do not maintain plane_mask so |
| 339 | * drivers not converted over to atomic helpers should not rely |
| 340 | * on plane_mask being accurate! |
| 341 | */ |
| 342 | u32 plane_mask; |
| 343 | |
Maarten Lankhorst | 4cd9fa5 | 2016-01-04 12:53:18 +0100 | [diff] [blame] | 344 | u32 connector_mask; |
Maarten Lankhorst | e87a52b | 2016-01-28 15:04:58 +0100 | [diff] [blame] | 345 | u32 encoder_mask; |
Maarten Lankhorst | 4cd9fa5 | 2016-01-04 12:53:18 +0100 | [diff] [blame] | 346 | |
Daniel Vetter | 623369e | 2014-09-16 17:50:47 +0200 | [diff] [blame] | 347 | /* last_vblank_count: for vblank waits before cleanup */ |
| 348 | u32 last_vblank_count; |
Daniel Vetter | c2fcd27 | 2014-11-05 00:14:14 +0100 | [diff] [blame] | 349 | |
Daniel Vetter | 2f324b4 | 2014-10-29 11:13:47 +0100 | [diff] [blame] | 350 | /* adjusted_mode: for use by helpers and drivers */ |
| 351 | struct drm_display_mode adjusted_mode; |
| 352 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 353 | struct drm_display_mode mode; |
| 354 | |
Daniel Stone | 99cf4a2 | 2015-05-25 19:11:51 +0100 | [diff] [blame] | 355 | /* blob property to expose current mode to atomic userspace */ |
| 356 | struct drm_property_blob *mode_blob; |
| 357 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 358 | struct drm_pending_vblank_event *event; |
| 359 | |
| 360 | struct drm_atomic_state *state; |
| 361 | }; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 362 | |
| 363 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 364 | * struct drm_crtc_funcs - control CRTCs for a given device |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 365 | * |
| 366 | * The drm_crtc_funcs structure is the central CRTC management structure |
| 367 | * in the DRM. Each CRTC controls one or more connectors (note that the name |
| 368 | * CRTC is simply historical, a CRTC may control LVDS, VGA, DVI, TV out, etc. |
| 369 | * connectors, not just CRTs). |
| 370 | * |
| 371 | * Each driver is responsible for filling out this structure at startup time, |
| 372 | * in addition to providing other modesetting features, like i2c and DDC |
| 373 | * bus accessors. |
| 374 | */ |
| 375 | struct drm_crtc_funcs { |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 376 | /** |
| 377 | * @reset: |
| 378 | * |
| 379 | * Reset CRTC hardware and software state to off. This function isn't |
| 380 | * called by the core directly, only through drm_mode_config_reset(). |
| 381 | * It's not a helper hook only for historical reasons. |
| 382 | * |
| 383 | * Atomic drivers can use drm_atomic_helper_crtc_reset() to reset |
| 384 | * atomic state using this hook. |
| 385 | */ |
Chris Wilson | eb03355 | 2011-01-24 15:11:08 +0000 | [diff] [blame] | 386 | void (*reset)(struct drm_crtc *crtc); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 387 | |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 388 | /** |
| 389 | * @cursor_set: |
| 390 | * |
| 391 | * Update the cursor image. The cursor position is relative to the CRTC |
| 392 | * and can be partially or fully outside of the visible area. |
| 393 | * |
| 394 | * Note that contrary to all other KMS functions the legacy cursor entry |
| 395 | * points don't take a framebuffer object, but instead take directly a |
| 396 | * raw buffer object id from the driver's buffer manager (which is |
| 397 | * either GEM or TTM for current drivers). |
| 398 | * |
| 399 | * This entry point is deprecated, drivers should instead implement |
| 400 | * universal plane support and register a proper cursor plane using |
| 401 | * drm_crtc_init_with_planes(). |
| 402 | * |
| 403 | * This callback is optional |
| 404 | * |
| 405 | * RETURNS: |
| 406 | * |
| 407 | * 0 on success or a negative error code on failure. |
| 408 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 409 | int (*cursor_set)(struct drm_crtc *crtc, struct drm_file *file_priv, |
| 410 | uint32_t handle, uint32_t width, uint32_t height); |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 411 | |
| 412 | /** |
| 413 | * @cursor_set2: |
| 414 | * |
| 415 | * Update the cursor image, including hotspot information. The hotspot |
| 416 | * must not affect the cursor position in CRTC coordinates, but is only |
| 417 | * meant as a hint for virtualized display hardware to coordinate the |
| 418 | * guests and hosts cursor position. The cursor hotspot is relative to |
| 419 | * the cursor image. Otherwise this works exactly like @cursor_set. |
| 420 | * |
| 421 | * This entry point is deprecated, drivers should instead implement |
| 422 | * universal plane support and register a proper cursor plane using |
| 423 | * drm_crtc_init_with_planes(). |
| 424 | * |
| 425 | * This callback is optional. |
| 426 | * |
| 427 | * RETURNS: |
| 428 | * |
| 429 | * 0 on success or a negative error code on failure. |
| 430 | */ |
Dave Airlie | 4c813d4 | 2013-06-20 11:48:52 +1000 | [diff] [blame] | 431 | int (*cursor_set2)(struct drm_crtc *crtc, struct drm_file *file_priv, |
| 432 | uint32_t handle, uint32_t width, uint32_t height, |
| 433 | int32_t hot_x, int32_t hot_y); |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 434 | |
| 435 | /** |
| 436 | * @cursor_move: |
| 437 | * |
| 438 | * Update the cursor position. The cursor does not need to be visible |
| 439 | * when this hook is called. |
| 440 | * |
| 441 | * This entry point is deprecated, drivers should instead implement |
| 442 | * universal plane support and register a proper cursor plane using |
| 443 | * drm_crtc_init_with_planes(). |
| 444 | * |
| 445 | * This callback is optional. |
| 446 | * |
| 447 | * RETURNS: |
| 448 | * |
| 449 | * 0 on success or a negative error code on failure. |
| 450 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 451 | int (*cursor_move)(struct drm_crtc *crtc, int x, int y); |
| 452 | |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 453 | /** |
| 454 | * @gamma_set: |
| 455 | * |
| 456 | * Set gamma on the CRTC. |
| 457 | * |
| 458 | * This callback is optional. |
| 459 | * |
| 460 | * NOTE: |
| 461 | * |
| 462 | * Drivers that support gamma tables and also fbdev emulation through |
| 463 | * the provided helper library need to take care to fill out the gamma |
| 464 | * hooks for both. Currently there's a bit an unfortunate duplication |
| 465 | * going on, which should eventually be unified to just one set of |
| 466 | * hooks. |
| 467 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 468 | void (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, |
James Simmons | 7203425 | 2010-08-03 01:33:19 +0100 | [diff] [blame] | 469 | uint32_t start, uint32_t size); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 470 | |
| 471 | /** |
| 472 | * @destroy: |
| 473 | * |
| 474 | * Clean up plane resources. This is only called at driver unload time |
| 475 | * through drm_mode_config_cleanup() since a CRTC cannot be hotplugged |
| 476 | * in DRM. |
| 477 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 478 | void (*destroy)(struct drm_crtc *crtc); |
| 479 | |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 480 | /** |
| 481 | * @set_config: |
| 482 | * |
| 483 | * This is the main legacy entry point to change the modeset state on a |
| 484 | * CRTC. All the details of the desired configuration are passed in a |
| 485 | * struct &drm_mode_set - see there for details. |
| 486 | * |
| 487 | * Drivers implementing atomic modeset should use |
| 488 | * drm_atomic_helper_set_config() to implement this hook. |
| 489 | * |
| 490 | * RETURNS: |
| 491 | * |
| 492 | * 0 on success or a negative error code on failure. |
| 493 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 494 | int (*set_config)(struct drm_mode_set *set); |
Kristian Høgsberg | d91d8a3 | 2009-11-17 12:43:55 -0500 | [diff] [blame] | 495 | |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 496 | /** |
| 497 | * @page_flip: |
| 498 | * |
| 499 | * Legacy entry point to schedule a flip to the given framebuffer. |
| 500 | * |
| 501 | * Page flipping is a synchronization mechanism that replaces the frame |
| 502 | * buffer being scanned out by the CRTC with a new frame buffer during |
| 503 | * vertical blanking, avoiding tearing (except when requested otherwise |
| 504 | * through the DRM_MODE_PAGE_FLIP_ASYNC flag). When an application |
| 505 | * requests a page flip the DRM core verifies that the new frame buffer |
| 506 | * is large enough to be scanned out by the CRTC in the currently |
| 507 | * configured mode and then calls the CRTC ->page_flip() operation with a |
| 508 | * pointer to the new frame buffer. |
| 509 | * |
| 510 | * The driver must wait for any pending rendering to the new framebuffer |
| 511 | * to complete before executing the flip. It should also wait for any |
| 512 | * pending rendering from other drivers if the underlying buffer is a |
| 513 | * shared dma-buf. |
| 514 | * |
| 515 | * An application can request to be notified when the page flip has |
| 516 | * completed. The drm core will supply a struct &drm_event in the event |
| 517 | * parameter in this case. This can be handled by the |
| 518 | * drm_crtc_send_vblank_event() function, which the driver should call on |
| 519 | * the provided event upon completion of the flip. Note that if |
| 520 | * the driver supports vblank signalling and timestamping the vblank |
| 521 | * counters and timestamps must agree with the ones returned from page |
| 522 | * flip events. With the current vblank helper infrastructure this can |
| 523 | * be achieved by holding a vblank reference while the page flip is |
| 524 | * pending, acquired through drm_crtc_vblank_get() and released with |
| 525 | * drm_crtc_vblank_put(). Drivers are free to implement their own vblank |
| 526 | * counter and timestamp tracking though, e.g. if they have accurate |
| 527 | * timestamp registers in hardware. |
| 528 | * |
| 529 | * FIXME: |
| 530 | * |
| 531 | * Up to that point drivers need to manage events themselves and can use |
| 532 | * even->base.list freely for that. Specifically they need to ensure |
| 533 | * that they don't send out page flip (or vblank) events for which the |
| 534 | * corresponding drm file has been closed already. The drm core |
| 535 | * unfortunately does not (yet) take care of that. Therefore drivers |
| 536 | * currently must clean up and release pending events in their |
| 537 | * ->preclose driver function. |
| 538 | * |
| 539 | * This callback is optional. |
| 540 | * |
| 541 | * NOTE: |
| 542 | * |
| 543 | * Very early versions of the KMS ABI mandated that the driver must |
| 544 | * block (but not reject) any rendering to the old framebuffer until the |
| 545 | * flip operation has completed and the old framebuffer is no longer |
| 546 | * visible. This requirement has been lifted, and userspace is instead |
| 547 | * expected to request delivery of an event and wait with recycling old |
| 548 | * buffers until such has been received. |
| 549 | * |
| 550 | * RETURNS: |
| 551 | * |
| 552 | * 0 on success or a negative error code on failure. Note that if a |
| 553 | * ->page_flip() operation is already pending the callback should return |
| 554 | * -EBUSY. Pageflips on a disabled CRTC (either by setting a NULL mode |
| 555 | * or just runtime disabled through DPMS respectively the new atomic |
Daniel Vetter | 4cba685 | 2015-12-08 09:49:20 +0100 | [diff] [blame] | 556 | * "ACTIVE" state) should result in an -EINVAL error code. Note that |
| 557 | * drm_atomic_helper_page_flip() checks this already for atomic drivers. |
Kristian Høgsberg | d91d8a3 | 2009-11-17 12:43:55 -0500 | [diff] [blame] | 558 | */ |
| 559 | int (*page_flip)(struct drm_crtc *crtc, |
| 560 | struct drm_framebuffer *fb, |
Keith Packard | ed8d197 | 2013-07-22 18:49:58 -0700 | [diff] [blame] | 561 | struct drm_pending_vblank_event *event, |
| 562 | uint32_t flags); |
Paulo Zanoni | bffd9de0 | 2012-05-15 18:09:05 -0300 | [diff] [blame] | 563 | |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 564 | /** |
| 565 | * @set_property: |
| 566 | * |
| 567 | * This is the legacy entry point to update a property attached to the |
| 568 | * CRTC. |
| 569 | * |
| 570 | * Drivers implementing atomic modeset should use |
| 571 | * drm_atomic_helper_crtc_set_property() to implement this hook. |
| 572 | * |
| 573 | * This callback is optional if the driver does not support any legacy |
| 574 | * driver-private properties. |
| 575 | * |
| 576 | * RETURNS: |
| 577 | * |
| 578 | * 0 on success or a negative error code on failure. |
| 579 | */ |
Paulo Zanoni | bffd9de0 | 2012-05-15 18:09:05 -0300 | [diff] [blame] | 580 | int (*set_property)(struct drm_crtc *crtc, |
| 581 | struct drm_property *property, uint64_t val); |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 582 | |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 583 | /** |
| 584 | * @atomic_duplicate_state: |
| 585 | * |
| 586 | * Duplicate the current atomic state for this CRTC and return it. |
| 587 | * The core and helpers gurantee that any atomic state duplicated with |
| 588 | * this hook and still owned by the caller (i.e. not transferred to the |
| 589 | * driver by calling ->atomic_commit() from struct |
| 590 | * &drm_mode_config_funcs) will be cleaned up by calling the |
| 591 | * @atomic_destroy_state hook in this structure. |
| 592 | * |
| 593 | * Atomic drivers which don't subclass struct &drm_crtc should use |
| 594 | * drm_atomic_helper_crtc_duplicate_state(). Drivers that subclass the |
| 595 | * state structure to extend it with driver-private state should use |
| 596 | * __drm_atomic_helper_crtc_duplicate_state() to make sure shared state is |
| 597 | * duplicated in a consistent fashion across drivers. |
| 598 | * |
| 599 | * It is an error to call this hook before crtc->state has been |
| 600 | * initialized correctly. |
| 601 | * |
| 602 | * NOTE: |
| 603 | * |
| 604 | * If the duplicate state references refcounted resources this hook must |
| 605 | * acquire a reference for each of them. The driver must release these |
| 606 | * references again in @atomic_destroy_state. |
| 607 | * |
| 608 | * RETURNS: |
| 609 | * |
| 610 | * Duplicated atomic state or NULL when the allocation failed. |
| 611 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 612 | struct drm_crtc_state *(*atomic_duplicate_state)(struct drm_crtc *crtc); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 613 | |
| 614 | /** |
| 615 | * @atomic_destroy_state: |
| 616 | * |
| 617 | * Destroy a state duplicated with @atomic_duplicate_state and release |
| 618 | * or unreference all resources it references |
| 619 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 620 | void (*atomic_destroy_state)(struct drm_crtc *crtc, |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 621 | struct drm_crtc_state *state); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 622 | |
| 623 | /** |
| 624 | * @atomic_set_property: |
| 625 | * |
| 626 | * Decode a driver-private property value and store the decoded value |
| 627 | * into the passed-in state structure. Since the atomic core decodes all |
| 628 | * standardized properties (even for extensions beyond the core set of |
| 629 | * properties which might not be implemented by all drivers) this |
| 630 | * requires drivers to subclass the state structure. |
| 631 | * |
| 632 | * Such driver-private properties should really only be implemented for |
| 633 | * truly hardware/vendor specific state. Instead it is preferred to |
| 634 | * standardize atomic extension and decode the properties used to expose |
| 635 | * such an extension in the core. |
| 636 | * |
| 637 | * Do not call this function directly, use |
| 638 | * drm_atomic_crtc_set_property() instead. |
| 639 | * |
| 640 | * This callback is optional if the driver does not support any |
| 641 | * driver-private atomic properties. |
| 642 | * |
| 643 | * NOTE: |
| 644 | * |
| 645 | * This function is called in the state assembly phase of atomic |
| 646 | * modesets, which can be aborted for any reason (including on |
| 647 | * userspace's request to just check whether a configuration would be |
| 648 | * possible). Drivers MUST NOT touch any persistent state (hardware or |
| 649 | * software) or data structures except the passed in @state parameter. |
| 650 | * |
| 651 | * Also since userspace controls in which order properties are set this |
| 652 | * function must not do any input validation (since the state update is |
| 653 | * incomplete and hence likely inconsistent). Instead any such input |
| 654 | * validation must be done in the various atomic_check callbacks. |
| 655 | * |
| 656 | * RETURNS: |
| 657 | * |
| 658 | * 0 if the property has been found, -EINVAL if the property isn't |
| 659 | * implemented by the driver (which should never happen, the core only |
| 660 | * asks for properties attached to this CRTC). No other validation is |
| 661 | * allowed by the driver. The core already checks that the property |
| 662 | * value is within the range (integer, valid enum value, ...) the driver |
| 663 | * set when registering the property. |
| 664 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 665 | int (*atomic_set_property)(struct drm_crtc *crtc, |
| 666 | struct drm_crtc_state *state, |
| 667 | struct drm_property *property, |
| 668 | uint64_t val); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 669 | /** |
| 670 | * @atomic_get_property: |
| 671 | * |
| 672 | * Reads out the decoded driver-private property. This is used to |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 673 | * implement the GETCRTC IOCTL. |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 674 | * |
| 675 | * Do not call this function directly, use |
| 676 | * drm_atomic_crtc_get_property() instead. |
| 677 | * |
| 678 | * This callback is optional if the driver does not support any |
| 679 | * driver-private atomic properties. |
| 680 | * |
| 681 | * RETURNS: |
| 682 | * |
| 683 | * 0 on success, -EINVAL if the property isn't implemented by the |
| 684 | * driver (which should never happen, the core only asks for |
| 685 | * properties attached to this CRTC). |
| 686 | */ |
Rob Clark | ac9c925 | 2014-12-18 16:01:47 -0500 | [diff] [blame] | 687 | int (*atomic_get_property)(struct drm_crtc *crtc, |
| 688 | const struct drm_crtc_state *state, |
| 689 | struct drm_property *property, |
| 690 | uint64_t *val); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 691 | }; |
| 692 | |
| 693 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 694 | * struct drm_crtc - central CRTC control structure |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 695 | * @dev: parent DRM device |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 696 | * @port: OF node used by drm_of_find_possible_crtcs() |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 697 | * @head: list management |
Rob Clark | 51fd371 | 2013-11-19 12:10:12 -0500 | [diff] [blame] | 698 | * @mutex: per-CRTC locking |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 699 | * @base: base KMS object for ID tracking etc. |
Matt Roper | e13161a | 2014-04-01 15:22:38 -0700 | [diff] [blame] | 700 | * @primary: primary plane for this CRTC |
| 701 | * @cursor: cursor plane for this CRTC |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 702 | * @cursor_x: current x position of the cursor, used for universal cursor planes |
| 703 | * @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] | 704 | * @enabled: is this CRTC enabled? |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 705 | * @mode: current mode timings |
| 706 | * @hwmode: mode timings as programmed to hw regs |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 707 | * @x: x position on screen |
| 708 | * @y: y position on screen |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 709 | * @funcs: CRTC control functions |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 710 | * @gamma_size: size of gamma ramp |
| 711 | * @gamma_store: gamma ramp values |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 712 | * @helper_private: mid-layer private data |
Paulo Zanoni | bffd9de0 | 2012-05-15 18:09:05 -0300 | [diff] [blame] | 713 | * @properties: property tracking for this CRTC |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 714 | * @state: current atomic state for this CRTC |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 715 | * @acquire_ctx: per-CRTC implicit acquire context used by atomic drivers for |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 716 | * legacy IOCTLs |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 717 | * |
| 718 | * Each CRTC may have one or more connectors associated with it. This structure |
| 719 | * allows the CRTC to be controlled. |
| 720 | */ |
| 721 | struct drm_crtc { |
| 722 | struct drm_device *dev; |
Russell King | 7e435aa | 2014-06-15 11:07:12 +0100 | [diff] [blame] | 723 | struct device_node *port; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 724 | struct list_head head; |
| 725 | |
Ville Syrjälä | fa3ab4c | 2015-12-08 18:41:53 +0200 | [diff] [blame] | 726 | char *name; |
| 727 | |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 728 | /* |
Daniel Vetter | 29494c1 | 2012-12-02 02:18:25 +0100 | [diff] [blame] | 729 | * crtc mutex |
| 730 | * |
| 731 | * This provides a read lock for the overall crtc state (mode, dpms |
| 732 | * state, ...) and a write lock for everything which can be update |
| 733 | * without a full modeset (fb, cursor data, ...) |
| 734 | */ |
Rob Clark | 51fd371 | 2013-11-19 12:10:12 -0500 | [diff] [blame] | 735 | struct drm_modeset_lock mutex; |
Daniel Vetter | 29494c1 | 2012-12-02 02:18:25 +0100 | [diff] [blame] | 736 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 737 | struct drm_mode_object base; |
| 738 | |
Matt Roper | e13161a | 2014-04-01 15:22:38 -0700 | [diff] [blame] | 739 | /* primary and cursor planes for CRTC */ |
| 740 | struct drm_plane *primary; |
| 741 | struct drm_plane *cursor; |
| 742 | |
Matt Roper | 161d0dc | 2014-06-10 08:28:10 -0700 | [diff] [blame] | 743 | /* position of cursor plane on crtc */ |
| 744 | int cursor_x; |
| 745 | int cursor_y; |
| 746 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 747 | bool enabled; |
| 748 | |
Mario Kleiner | 27641c3 | 2010-10-23 04:20:23 +0200 | [diff] [blame] | 749 | /* Requested mode from modesetting. */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 750 | struct drm_display_mode mode; |
| 751 | |
Mario Kleiner | 27641c3 | 2010-10-23 04:20:23 +0200 | [diff] [blame] | 752 | /* Programmed mode in hw, after adjustments for encoders, |
| 753 | * crtc, panel scaling etc. Needed for timestamping etc. |
| 754 | */ |
| 755 | struct drm_display_mode hwmode; |
| 756 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 757 | int x, y; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 758 | const struct drm_crtc_funcs *funcs; |
| 759 | |
| 760 | /* CRTC gamma size for reporting to userspace */ |
| 761 | uint32_t gamma_size; |
| 762 | uint16_t *gamma_store; |
| 763 | |
| 764 | /* if you are using the helper */ |
Daniel Vetter | 4490d4c | 2015-12-04 09:45:45 +0100 | [diff] [blame] | 765 | const struct drm_crtc_helper_funcs *helper_private; |
Paulo Zanoni | bffd9de0 | 2012-05-15 18:09:05 -0300 | [diff] [blame] | 766 | |
| 767 | struct drm_object_properties properties; |
Daniel Vetter | d059f65 | 2014-07-25 18:07:40 +0200 | [diff] [blame] | 768 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 769 | struct drm_crtc_state *state; |
| 770 | |
Daniel Vetter | d059f65 | 2014-07-25 18:07:40 +0200 | [diff] [blame] | 771 | /* |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 772 | * For legacy crtc IOCTLs so that atomic drivers can get at the locking |
Daniel Vetter | d059f65 | 2014-07-25 18:07:40 +0200 | [diff] [blame] | 773 | * acquire context. |
| 774 | */ |
| 775 | struct drm_modeset_acquire_ctx *acquire_ctx; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 776 | }; |
| 777 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 778 | /** |
| 779 | * struct drm_connector_state - mutable connector state |
Daniel Vetter | 07cc0ef | 2014-11-27 15:49:39 +0100 | [diff] [blame] | 780 | * @connector: backpointer to the connector |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 781 | * @crtc: CRTC to connect connector to, NULL if disabled |
Daniel Vetter | 623369e | 2014-09-16 17:50:47 +0200 | [diff] [blame] | 782 | * @best_encoder: can be used by helpers and drivers to select the encoder |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 783 | * @state: backpointer to global drm_atomic_state |
| 784 | */ |
| 785 | struct drm_connector_state { |
Daniel Vetter | 07cc0ef | 2014-11-27 15:49:39 +0100 | [diff] [blame] | 786 | struct drm_connector *connector; |
| 787 | |
Rob Clark | 6ddd388 | 2014-11-21 15:28:31 -0500 | [diff] [blame] | 788 | struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_connector() */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 789 | |
Daniel Vetter | 623369e | 2014-09-16 17:50:47 +0200 | [diff] [blame] | 790 | struct drm_encoder *best_encoder; |
| 791 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 792 | struct drm_atomic_state *state; |
| 793 | }; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 794 | |
| 795 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 796 | * struct drm_connector_funcs - control connectors on a given device |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 797 | * |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 798 | * Each CRTC may have one or more connectors attached to it. The functions |
| 799 | * below allow the core DRM code to control connectors, enumerate available modes, |
| 800 | * etc. |
| 801 | */ |
| 802 | struct drm_connector_funcs { |
Daniel Vetter | 6fe14ac | 2015-12-04 09:45:58 +0100 | [diff] [blame] | 803 | /** |
| 804 | * @dpms: |
| 805 | * |
| 806 | * Legacy entry point to set the per-connector DPMS state. Legacy DPMS |
| 807 | * is exposed as a standard property on the connector, but diverted to |
| 808 | * this callback in the drm core. Note that atomic drivers don't |
| 809 | * implement the 4 level DPMS support on the connector any more, but |
| 810 | * instead only have an on/off "ACTIVE" property on the CRTC object. |
| 811 | * |
| 812 | * Drivers implementing atomic modeset should use |
| 813 | * drm_atomic_helper_connector_dpms() to implement this hook. |
| 814 | * |
| 815 | * RETURNS: |
| 816 | * |
| 817 | * 0 on success or a negative error code on failure. |
| 818 | */ |
Maarten Lankhorst | 9a69a9a | 2015-07-21 11:34:55 +0200 | [diff] [blame] | 819 | int (*dpms)(struct drm_connector *connector, int mode); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 820 | |
| 821 | /** |
| 822 | * @reset: |
| 823 | * |
| 824 | * Reset connector hardware and software state to off. This function isn't |
| 825 | * called by the core directly, only through drm_mode_config_reset(). |
| 826 | * It's not a helper hook only for historical reasons. |
| 827 | * |
| 828 | * Atomic drivers can use drm_atomic_helper_connector_reset() to reset |
| 829 | * atomic state using this hook. |
| 830 | */ |
Chris Wilson | eb03355 | 2011-01-24 15:11:08 +0000 | [diff] [blame] | 831 | void (*reset)(struct drm_connector *connector); |
Chris Wilson | 930a9e2 | 2010-09-14 11:07:23 +0100 | [diff] [blame] | 832 | |
Daniel Vetter | 6fe14ac | 2015-12-04 09:45:58 +0100 | [diff] [blame] | 833 | /** |
| 834 | * @detect: |
| 835 | * |
| 836 | * Check to see if anything is attached to the connector. The parameter |
| 837 | * force is set to false whilst polling, true when checking the |
| 838 | * connector due to a user request. force can be used by the driver to |
| 839 | * avoid expensive, destructive operations during automated probing. |
| 840 | * |
| 841 | * FIXME: |
| 842 | * |
| 843 | * Note that this hook is only called by the probe helper. It's not in |
| 844 | * the helper library vtable purely for historical reasons. The only DRM |
| 845 | * core entry point to probe connector state is @fill_modes. |
| 846 | * |
| 847 | * RETURNS: |
| 848 | * |
| 849 | * drm_connector_status indicating the connector's status. |
Chris Wilson | 930a9e2 | 2010-09-14 11:07:23 +0100 | [diff] [blame] | 850 | */ |
Chris Wilson | 7b334fc | 2010-09-09 23:51:02 +0100 | [diff] [blame] | 851 | enum drm_connector_status (*detect)(struct drm_connector *connector, |
Chris Wilson | 930a9e2 | 2010-09-14 11:07:23 +0100 | [diff] [blame] | 852 | bool force); |
Daniel Vetter | 6fe14ac | 2015-12-04 09:45:58 +0100 | [diff] [blame] | 853 | |
| 854 | /** |
| 855 | * @force: |
| 856 | * |
| 857 | * This function is called to update internal encoder state when the |
| 858 | * connector is forced to a certain state by userspace, either through |
| 859 | * the sysfs interfaces or on the kernel cmdline. In that case the |
| 860 | * @detect callback isn't called. |
| 861 | * |
| 862 | * FIXME: |
| 863 | * |
| 864 | * Note that this hook is only called by the probe helper. It's not in |
| 865 | * the helper library vtable purely for historical reasons. The only DRM |
| 866 | * core entry point to probe connector state is @fill_modes. |
| 867 | */ |
| 868 | void (*force)(struct drm_connector *connector); |
| 869 | |
| 870 | /** |
| 871 | * @fill_modes: |
| 872 | * |
| 873 | * Entry point for output detection and basic mode validation. The |
| 874 | * driver should reprobe the output if needed (e.g. when hotplug |
| 875 | * handling is unreliable), add all detected modes to connector->modes |
| 876 | * and filter out any the device can't support in any configuration. It |
| 877 | * also needs to filter out any modes wider or higher than the |
| 878 | * parameters max_width and max_height indicate. |
| 879 | * |
| 880 | * The drivers must also prune any modes no longer valid from |
| 881 | * connector->modes. Furthermore it must update connector->status and |
| 882 | * connector->edid. If no EDID has been received for this output |
| 883 | * connector->edid must be NULL. |
| 884 | * |
| 885 | * Drivers using the probe helpers should use |
| 886 | * drm_helper_probe_single_connector_modes() or |
| 887 | * drm_helper_probe_single_connector_modes_nomerge() to implement this |
| 888 | * function. |
| 889 | * |
| 890 | * RETURNS: |
| 891 | * |
| 892 | * The number of modes detected and filled into connector->modes. |
| 893 | */ |
Jesse Barnes | 40a518d | 2009-01-12 12:05:32 -0800 | [diff] [blame] | 894 | int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 895 | |
| 896 | /** |
| 897 | * @set_property: |
| 898 | * |
| 899 | * This is the legacy entry point to update a property attached to the |
| 900 | * connector. |
| 901 | * |
| 902 | * Drivers implementing atomic modeset should use |
| 903 | * drm_atomic_helper_connector_set_property() to implement this hook. |
| 904 | * |
| 905 | * This callback is optional if the driver does not support any legacy |
| 906 | * driver-private properties. |
| 907 | * |
| 908 | * RETURNS: |
| 909 | * |
| 910 | * 0 on success or a negative error code on failure. |
| 911 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 912 | int (*set_property)(struct drm_connector *connector, struct drm_property *property, |
| 913 | uint64_t val); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 914 | |
| 915 | /** |
| 916 | * @destroy: |
| 917 | * |
| 918 | * Clean up connector resources. This is called at driver unload time |
| 919 | * through drm_mode_config_cleanup(). It can also be called at runtime |
| 920 | * when a connector is being hot-unplugged for drivers that support |
| 921 | * connector hotplugging (e.g. DisplayPort MST). |
| 922 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 923 | void (*destroy)(struct drm_connector *connector); |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 924 | |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 925 | /** |
| 926 | * @atomic_duplicate_state: |
| 927 | * |
| 928 | * Duplicate the current atomic state for this connector and return it. |
| 929 | * The core and helpers gurantee that any atomic state duplicated with |
| 930 | * this hook and still owned by the caller (i.e. not transferred to the |
| 931 | * driver by calling ->atomic_commit() from struct |
| 932 | * &drm_mode_config_funcs) will be cleaned up by calling the |
| 933 | * @atomic_destroy_state hook in this structure. |
| 934 | * |
| 935 | * Atomic drivers which don't subclass struct &drm_connector_state should use |
| 936 | * drm_atomic_helper_connector_duplicate_state(). Drivers that subclass the |
| 937 | * state structure to extend it with driver-private state should use |
| 938 | * __drm_atomic_helper_connector_duplicate_state() to make sure shared state is |
| 939 | * duplicated in a consistent fashion across drivers. |
| 940 | * |
| 941 | * It is an error to call this hook before connector->state has been |
| 942 | * initialized correctly. |
| 943 | * |
| 944 | * NOTE: |
| 945 | * |
| 946 | * If the duplicate state references refcounted resources this hook must |
| 947 | * acquire a reference for each of them. The driver must release these |
| 948 | * references again in @atomic_destroy_state. |
| 949 | * |
| 950 | * RETURNS: |
| 951 | * |
| 952 | * Duplicated atomic state or NULL when the allocation failed. |
| 953 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 954 | struct drm_connector_state *(*atomic_duplicate_state)(struct drm_connector *connector); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 955 | |
| 956 | /** |
| 957 | * @atomic_destroy_state: |
| 958 | * |
| 959 | * Destroy a state duplicated with @atomic_duplicate_state and release |
| 960 | * or unreference all resources it references |
| 961 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 962 | void (*atomic_destroy_state)(struct drm_connector *connector, |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 963 | struct drm_connector_state *state); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 964 | |
| 965 | /** |
| 966 | * @atomic_set_property: |
| 967 | * |
| 968 | * Decode a driver-private property value and store the decoded value |
| 969 | * into the passed-in state structure. Since the atomic core decodes all |
| 970 | * standardized properties (even for extensions beyond the core set of |
| 971 | * properties which might not be implemented by all drivers) this |
| 972 | * requires drivers to subclass the state structure. |
| 973 | * |
| 974 | * Such driver-private properties should really only be implemented for |
| 975 | * truly hardware/vendor specific state. Instead it is preferred to |
| 976 | * standardize atomic extension and decode the properties used to expose |
| 977 | * such an extension in the core. |
| 978 | * |
| 979 | * Do not call this function directly, use |
| 980 | * drm_atomic_connector_set_property() instead. |
| 981 | * |
| 982 | * This callback is optional if the driver does not support any |
| 983 | * driver-private atomic properties. |
| 984 | * |
| 985 | * NOTE: |
| 986 | * |
| 987 | * This function is called in the state assembly phase of atomic |
| 988 | * modesets, which can be aborted for any reason (including on |
| 989 | * userspace's request to just check whether a configuration would be |
| 990 | * possible). Drivers MUST NOT touch any persistent state (hardware or |
| 991 | * software) or data structures except the passed in @state parameter. |
| 992 | * |
| 993 | * Also since userspace controls in which order properties are set this |
| 994 | * function must not do any input validation (since the state update is |
| 995 | * incomplete and hence likely inconsistent). Instead any such input |
| 996 | * validation must be done in the various atomic_check callbacks. |
| 997 | * |
| 998 | * RETURNS: |
| 999 | * |
| 1000 | * 0 if the property has been found, -EINVAL if the property isn't |
| 1001 | * implemented by the driver (which shouldn't ever happen, the core only |
| 1002 | * asks for properties attached to this connector). No other validation |
| 1003 | * is allowed by the driver. The core already checks that the property |
| 1004 | * value is within the range (integer, valid enum value, ...) the driver |
| 1005 | * set when registering the property. |
| 1006 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1007 | int (*atomic_set_property)(struct drm_connector *connector, |
| 1008 | struct drm_connector_state *state, |
| 1009 | struct drm_property *property, |
| 1010 | uint64_t val); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1011 | |
| 1012 | /** |
| 1013 | * @atomic_get_property: |
| 1014 | * |
| 1015 | * Reads out the decoded driver-private property. This is used to |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 1016 | * implement the GETCONNECTOR IOCTL. |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1017 | * |
| 1018 | * Do not call this function directly, use |
| 1019 | * drm_atomic_connector_get_property() instead. |
| 1020 | * |
| 1021 | * This callback is optional if the driver does not support any |
| 1022 | * driver-private atomic properties. |
| 1023 | * |
| 1024 | * RETURNS: |
| 1025 | * |
| 1026 | * 0 on success, -EINVAL if the property isn't implemented by the |
| 1027 | * driver (which shouldn't ever happen, the core only asks for |
| 1028 | * properties attached to this connector). |
| 1029 | */ |
Rob Clark | ac9c925 | 2014-12-18 16:01:47 -0500 | [diff] [blame] | 1030 | int (*atomic_get_property)(struct drm_connector *connector, |
| 1031 | const struct drm_connector_state *state, |
| 1032 | struct drm_property *property, |
| 1033 | uint64_t *val); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1034 | }; |
| 1035 | |
Jesse Barnes | 6c3db92 | 2011-11-07 12:03:16 -0800 | [diff] [blame] | 1036 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 1037 | * struct drm_encoder_funcs - encoder controls |
Jesse Barnes | 6c3db92 | 2011-11-07 12:03:16 -0800 | [diff] [blame] | 1038 | * |
| 1039 | * Encoders sit between CRTCs and connectors. |
| 1040 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1041 | struct drm_encoder_funcs { |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1042 | /** |
| 1043 | * @reset: |
| 1044 | * |
| 1045 | * Reset encoder hardware and software state to off. This function isn't |
| 1046 | * called by the core directly, only through drm_mode_config_reset(). |
| 1047 | * It's not a helper hook only for historical reasons. |
| 1048 | */ |
Chris Wilson | eb03355 | 2011-01-24 15:11:08 +0000 | [diff] [blame] | 1049 | void (*reset)(struct drm_encoder *encoder); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1050 | |
| 1051 | /** |
| 1052 | * @destroy: |
| 1053 | * |
| 1054 | * Clean up encoder resources. This is only called at driver unload time |
| 1055 | * through drm_mode_config_cleanup() since an encoder cannot be |
| 1056 | * hotplugged in DRM. |
| 1057 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1058 | void (*destroy)(struct drm_encoder *encoder); |
| 1059 | }; |
| 1060 | |
Ben Skeggs | afe887d | 2012-01-12 16:00:57 +1000 | [diff] [blame] | 1061 | #define DRM_CONNECTOR_MAX_ENCODER 3 |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1062 | |
| 1063 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 1064 | * struct drm_encoder - central DRM encoder structure |
Jesse Barnes | db3e449 | 2011-11-07 12:03:17 -0800 | [diff] [blame] | 1065 | * @dev: parent DRM device |
| 1066 | * @head: list management |
| 1067 | * @base: base KMS object |
Jani Nikula | e574894 | 2014-05-14 16:58:20 +0300 | [diff] [blame] | 1068 | * @name: encoder name |
Jesse Barnes | db3e449 | 2011-11-07 12:03:17 -0800 | [diff] [blame] | 1069 | * @encoder_type: one of the %DRM_MODE_ENCODER_<foo> types in drm_mode.h |
| 1070 | * @possible_crtcs: bitmask of potential CRTC bindings |
| 1071 | * @possible_clones: bitmask of potential sibling encoders for cloning |
| 1072 | * @crtc: currently bound CRTC |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1073 | * @bridge: bridge associated to the encoder |
Jesse Barnes | db3e449 | 2011-11-07 12:03:17 -0800 | [diff] [blame] | 1074 | * @funcs: control functions |
| 1075 | * @helper_private: mid-layer private data |
| 1076 | * |
| 1077 | * CRTCs drive pixels to encoders, which convert them into signals |
| 1078 | * appropriate for a given connector or set of connectors. |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1079 | */ |
| 1080 | struct drm_encoder { |
| 1081 | struct drm_device *dev; |
| 1082 | struct list_head head; |
| 1083 | |
| 1084 | struct drm_mode_object base; |
Jani Nikula | e574894 | 2014-05-14 16:58:20 +0300 | [diff] [blame] | 1085 | char *name; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1086 | int encoder_type; |
| 1087 | uint32_t possible_crtcs; |
| 1088 | uint32_t possible_clones; |
| 1089 | |
| 1090 | struct drm_crtc *crtc; |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1091 | struct drm_bridge *bridge; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1092 | const struct drm_encoder_funcs *funcs; |
Daniel Vetter | 4490d4c | 2015-12-04 09:45:45 +0100 | [diff] [blame] | 1093 | const struct drm_encoder_helper_funcs *helper_private; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1094 | }; |
| 1095 | |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 1096 | /* should we poll this connector for connects and disconnects */ |
| 1097 | /* hot plug detectable */ |
| 1098 | #define DRM_CONNECTOR_POLL_HPD (1 << 0) |
| 1099 | /* poll for connections */ |
| 1100 | #define DRM_CONNECTOR_POLL_CONNECT (1 << 1) |
| 1101 | /* can cleanly poll for disconnections without flickering the screen */ |
| 1102 | /* DACs should rarely do this without a lot of testing */ |
| 1103 | #define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2) |
| 1104 | |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 1105 | #define MAX_ELD_BYTES 128 |
| 1106 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1107 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 1108 | * struct drm_connector - central DRM connector control structure |
Jesse Barnes | 7225254 | 2011-11-07 12:03:18 -0800 | [diff] [blame] | 1109 | * @dev: parent DRM device |
| 1110 | * @kdev: kernel device for sysfs attributes |
| 1111 | * @attr: sysfs attributes |
| 1112 | * @head: list management |
| 1113 | * @base: base KMS object |
Jani Nikula | 2abdd31 | 2014-05-14 16:58:19 +0300 | [diff] [blame] | 1114 | * @name: connector name |
Jesse Barnes | 7225254 | 2011-11-07 12:03:18 -0800 | [diff] [blame] | 1115 | * @connector_type: one of the %DRM_MODE_CONNECTOR_<foo> types from drm_mode.h |
| 1116 | * @connector_type_id: index into connector type enum |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1117 | * @interlace_allowed: can this connector handle interlaced modes? |
| 1118 | * @doublescan_allowed: can this connector handle doublescan? |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1119 | * @stereo_allowed: can this connector handle stereo modes? |
Jesse Barnes | 7225254 | 2011-11-07 12:03:18 -0800 | [diff] [blame] | 1120 | * @modes: modes available on this connector (from fill_modes() + user) |
| 1121 | * @status: one of the drm_connector_status enums (connected, not, or unknown) |
| 1122 | * @probed_modes: list of modes derived directly from the display |
| 1123 | * @display_info: information about attached display (e.g. from EDID) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1124 | * @funcs: connector control functions |
Jesse Barnes | 7225254 | 2011-11-07 12:03:18 -0800 | [diff] [blame] | 1125 | * @edid_blob_ptr: DRM property containing EDID if present |
Paulo Zanoni | 7e3bdf4 | 2012-05-15 18:09:01 -0300 | [diff] [blame] | 1126 | * @properties: property tracking for this connector |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1127 | * @path_blob_ptr: DRM blob property data for the DP MST path property |
Jesse Barnes | 7225254 | 2011-11-07 12:03:18 -0800 | [diff] [blame] | 1128 | * @polled: a %DRM_CONNECTOR_POLL_<foo> value for core driven polling |
| 1129 | * @dpms: current dpms state |
| 1130 | * @helper_private: mid-layer private data |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1131 | * @cmdline_mode: mode line parsed from the kernel cmdline for this connector |
Jesse Barnes | 7225254 | 2011-11-07 12:03:18 -0800 | [diff] [blame] | 1132 | * @force: a %DRM_FORCE_<foo> state for forced mode sets |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1133 | * @override_edid: has the EDID been overwritten through debugfs for testing? |
Jesse Barnes | 7225254 | 2011-11-07 12:03:18 -0800 | [diff] [blame] | 1134 | * @encoder_ids: valid encoders for this connector |
| 1135 | * @encoder: encoder driving this connector, if any |
| 1136 | * @eld: EDID-like data, if present |
| 1137 | * @dvi_dual: dual link DVI, if found |
| 1138 | * @max_tmds_clock: max clock rate, if found |
| 1139 | * @latency_present: AV delay info from ELD, if found |
| 1140 | * @video_latency: video latency info from ELD, if found |
| 1141 | * @audio_latency: audio latency info from ELD, if found |
| 1142 | * @null_edid_counter: track sinks that give us all zeros for the EDID |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1143 | * @bad_edid_counter: track sinks that give us an EDID with invalid checksum |
Daniel Vetter | ac6f2e2 | 2015-05-08 16:15:41 +0200 | [diff] [blame] | 1144 | * @edid_corrupt: indicates whether the last read EDID was corrupt |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1145 | * @debugfs_entry: debugfs directory for this connector |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1146 | * @state: current atomic state for this connector |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 1147 | * @has_tile: is this connector connected to a tiled monitor |
| 1148 | * @tile_group: tile group for the connected monitor |
| 1149 | * @tile_is_single_monitor: whether the tile is one monitor housing |
| 1150 | * @num_h_tile: number of horizontal tiles in the tile group |
| 1151 | * @num_v_tile: number of vertical tiles in the tile group |
| 1152 | * @tile_h_loc: horizontal location of this tile |
| 1153 | * @tile_v_loc: vertical location of this tile |
| 1154 | * @tile_h_size: horizontal size of this tile. |
| 1155 | * @tile_v_size: vertical size of this tile. |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1156 | * |
| 1157 | * Each connector may be connected to one or more CRTCs, or may be clonable by |
| 1158 | * another connector if they can share a CRTC. Each connector also has a specific |
| 1159 | * position in the broader display (referred to as a 'screen' though it could |
| 1160 | * span multiple monitors). |
| 1161 | */ |
| 1162 | struct drm_connector { |
| 1163 | struct drm_device *dev; |
Dave Airlie | 5bdebb1 | 2013-10-11 14:07:25 +1000 | [diff] [blame] | 1164 | struct device *kdev; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1165 | struct device_attribute *attr; |
| 1166 | struct list_head head; |
| 1167 | |
| 1168 | struct drm_mode_object base; |
| 1169 | |
Jani Nikula | 2abdd31 | 2014-05-14 16:58:19 +0300 | [diff] [blame] | 1170 | char *name; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1171 | int connector_type; |
| 1172 | int connector_type_id; |
| 1173 | bool interlace_allowed; |
| 1174 | bool doublescan_allowed; |
Damien Lespiau | 560a067 | 2013-09-25 16:45:29 +0100 | [diff] [blame] | 1175 | bool stereo_allowed; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1176 | struct list_head modes; /* list of modes on this connector */ |
| 1177 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1178 | enum drm_connector_status status; |
| 1179 | |
| 1180 | /* these are modes added by probing with DDC or the BIOS */ |
| 1181 | struct list_head probed_modes; |
| 1182 | |
| 1183 | struct drm_display_info display_info; |
| 1184 | const struct drm_connector_funcs *funcs; |
| 1185 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1186 | struct drm_property_blob *edid_blob_ptr; |
Paulo Zanoni | 7e3bdf4 | 2012-05-15 18:09:01 -0300 | [diff] [blame] | 1187 | struct drm_object_properties properties; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1188 | |
Dave Airlie | 43aba7e | 2014-06-05 14:01:31 +1000 | [diff] [blame] | 1189 | struct drm_property_blob *path_blob_ptr; |
| 1190 | |
Dave Airlie | 6f134d7 | 2014-10-20 16:30:50 +1000 | [diff] [blame] | 1191 | struct drm_property_blob *tile_blob_ptr; |
| 1192 | |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 1193 | uint8_t polled; /* DRM_CONNECTOR_POLL_* */ |
| 1194 | |
Keith Packard | c9fb15f | 2009-05-30 20:42:28 -0700 | [diff] [blame] | 1195 | /* requested DPMS state */ |
| 1196 | int dpms; |
| 1197 | |
Daniel Vetter | 4490d4c | 2015-12-04 09:45:45 +0100 | [diff] [blame] | 1198 | const struct drm_connector_helper_funcs *helper_private; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1199 | |
Dave Airlie | d50ba25 | 2009-09-23 14:44:08 +1000 | [diff] [blame] | 1200 | /* forced on connector */ |
Chris Wilson | eaf99c7 | 2014-08-06 10:08:32 +0200 | [diff] [blame] | 1201 | struct drm_cmdline_mode cmdline_mode; |
Dave Airlie | d50ba25 | 2009-09-23 14:44:08 +1000 | [diff] [blame] | 1202 | enum drm_connector_force force; |
Thomas Wood | 4cf2b28 | 2014-06-18 17:52:33 +0100 | [diff] [blame] | 1203 | bool override_edid; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1204 | uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER]; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1205 | struct drm_encoder *encoder; /* currently active encoder */ |
Dave Airlie | 4a9a8b7 | 2011-06-14 06:13:55 +0000 | [diff] [blame] | 1206 | |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 1207 | /* EDID bits */ |
| 1208 | uint8_t eld[MAX_ELD_BYTES]; |
| 1209 | bool dvi_dual; |
| 1210 | int max_tmds_clock; /* in MHz */ |
| 1211 | bool latency_present[2]; |
| 1212 | int video_latency[2]; /* [0]: progressive, [1]: interlaced */ |
| 1213 | int audio_latency[2]; |
Dave Airlie | 4a9a8b7 | 2011-06-14 06:13:55 +0000 | [diff] [blame] | 1214 | int null_edid_counter; /* needed to workaround some HW bugs where we get all 0s */ |
Jerome Glisse | 0b2443e | 2012-08-09 11:25:51 -0400 | [diff] [blame] | 1215 | unsigned bad_edid_counter; |
Thomas Wood | 30f6570 | 2014-06-18 17:52:32 +0100 | [diff] [blame] | 1216 | |
Todd Previte | 6ba2bd3 | 2015-04-21 11:09:41 -0700 | [diff] [blame] | 1217 | /* Flag for raw EDID header corruption - used in Displayport |
| 1218 | * compliance testing - * Displayport Link CTS Core 1.2 rev1.1 4.2.2.6 |
| 1219 | */ |
| 1220 | bool edid_corrupt; |
| 1221 | |
Thomas Wood | 30f6570 | 2014-06-18 17:52:32 +0100 | [diff] [blame] | 1222 | struct dentry *debugfs_entry; |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1223 | |
| 1224 | struct drm_connector_state *state; |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 1225 | |
| 1226 | /* DisplayID bits */ |
| 1227 | bool has_tile; |
| 1228 | struct drm_tile_group *tile_group; |
| 1229 | bool tile_is_single_monitor; |
| 1230 | |
| 1231 | uint8_t num_h_tile, num_v_tile; |
| 1232 | uint8_t tile_h_loc, tile_v_loc; |
| 1233 | uint16_t tile_h_size, tile_v_size; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1234 | }; |
| 1235 | |
| 1236 | /** |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1237 | * struct drm_plane_state - mutable plane state |
Daniel Vetter | 07cc0ef | 2014-11-27 15:49:39 +0100 | [diff] [blame] | 1238 | * @plane: backpointer to the plane |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1239 | * @crtc: currently bound CRTC, NULL if disabled |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1240 | * @fb: currently bound framebuffer |
Daniel Vetter | e2330f0 | 2014-10-29 11:34:56 +0100 | [diff] [blame] | 1241 | * @fence: optional fence to wait for before scanning out @fb |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1242 | * @crtc_x: left position of visible portion of plane on crtc |
| 1243 | * @crtc_y: upper position of visible portion of plane on crtc |
| 1244 | * @crtc_w: width of visible portion of plane on crtc |
| 1245 | * @crtc_h: height of visible portion of plane on crtc |
| 1246 | * @src_x: left position of visible portion of plane within |
| 1247 | * plane (in 16.16) |
| 1248 | * @src_y: upper position of visible portion of plane within |
| 1249 | * plane (in 16.16) |
| 1250 | * @src_w: width of visible portion of plane (in 16.16) |
| 1251 | * @src_h: height of visible portion of plane (in 16.16) |
| 1252 | * @state: backpointer to global drm_atomic_state |
| 1253 | */ |
| 1254 | struct drm_plane_state { |
Daniel Vetter | 07cc0ef | 2014-11-27 15:49:39 +0100 | [diff] [blame] | 1255 | struct drm_plane *plane; |
| 1256 | |
Rob Clark | 6ddd388 | 2014-11-21 15:28:31 -0500 | [diff] [blame] | 1257 | struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_plane() */ |
| 1258 | 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] | 1259 | struct fence *fence; |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1260 | |
| 1261 | /* Signed dest location allows it to be partially off screen */ |
| 1262 | int32_t crtc_x, crtc_y; |
| 1263 | uint32_t crtc_w, crtc_h; |
| 1264 | |
| 1265 | /* Source values are 16.16 fixed point */ |
| 1266 | uint32_t src_x, src_y; |
| 1267 | uint32_t src_h, src_w; |
| 1268 | |
Matt Roper | 1da3062 | 2015-01-21 16:35:40 -0800 | [diff] [blame] | 1269 | /* Plane rotation */ |
| 1270 | unsigned int rotation; |
| 1271 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1272 | struct drm_atomic_state *state; |
| 1273 | }; |
| 1274 | |
| 1275 | |
| 1276 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 1277 | * struct drm_plane_funcs - driver plane control functions |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1278 | */ |
| 1279 | struct drm_plane_funcs { |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1280 | /** |
| 1281 | * @update_plane: |
| 1282 | * |
| 1283 | * This is the legacy entry point to enable and configure the plane for |
| 1284 | * the given CRTC and framebuffer. It is never called to disable the |
| 1285 | * plane, i.e. the passed-in crtc and fb paramters are never NULL. |
| 1286 | * |
| 1287 | * The source rectangle in frame buffer memory coordinates is given by |
| 1288 | * the src_x, src_y, src_w and src_h parameters (as 16.16 fixed point |
| 1289 | * values). Devices that don't support subpixel plane coordinates can |
| 1290 | * ignore the fractional part. |
| 1291 | * |
| 1292 | * The destination rectangle in CRTC coordinates is given by the |
| 1293 | * crtc_x, crtc_y, crtc_w and crtc_h parameters (as integer values). |
| 1294 | * Devices scale the source rectangle to the destination rectangle. If |
| 1295 | * scaling is not supported, and the source rectangle size doesn't match |
| 1296 | * the destination rectangle size, the driver must return a |
| 1297 | * -<errorname>EINVAL</errorname> error. |
| 1298 | * |
| 1299 | * Drivers implementing atomic modeset should use |
| 1300 | * drm_atomic_helper_update_plane() to implement this hook. |
| 1301 | * |
| 1302 | * RETURNS: |
| 1303 | * |
| 1304 | * 0 on success or a negative error code on failure. |
| 1305 | */ |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1306 | int (*update_plane)(struct drm_plane *plane, |
| 1307 | struct drm_crtc *crtc, struct drm_framebuffer *fb, |
| 1308 | int crtc_x, int crtc_y, |
| 1309 | unsigned int crtc_w, unsigned int crtc_h, |
| 1310 | uint32_t src_x, uint32_t src_y, |
| 1311 | uint32_t src_w, uint32_t src_h); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1312 | |
| 1313 | /** |
| 1314 | * @disable_plane: |
| 1315 | * |
| 1316 | * 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] | 1317 | * 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] | 1318 | * with the frame buffer ID set to 0. Disabled planes must not be |
| 1319 | * processed by the CRTC. |
| 1320 | * |
| 1321 | * Drivers implementing atomic modeset should use |
| 1322 | * drm_atomic_helper_disable_plane() to implement this hook. |
| 1323 | * |
| 1324 | * RETURNS: |
| 1325 | * |
| 1326 | * 0 on success or a negative error code on failure. |
| 1327 | */ |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1328 | int (*disable_plane)(struct drm_plane *plane); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1329 | |
| 1330 | /** |
| 1331 | * @destroy: |
| 1332 | * |
| 1333 | * Clean up plane resources. This is only called at driver unload time |
| 1334 | * through drm_mode_config_cleanup() since a plane cannot be hotplugged |
| 1335 | * in DRM. |
| 1336 | */ |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1337 | void (*destroy)(struct drm_plane *plane); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1338 | |
| 1339 | /** |
| 1340 | * @reset: |
| 1341 | * |
| 1342 | * Reset plane hardware and software state to off. This function isn't |
| 1343 | * called by the core directly, only through drm_mode_config_reset(). |
| 1344 | * It's not a helper hook only for historical reasons. |
| 1345 | * |
| 1346 | * Atomic drivers can use drm_atomic_helper_plane_reset() to reset |
| 1347 | * atomic state using this hook. |
| 1348 | */ |
Daniel Vetter | 2a0d7cf | 2014-07-29 15:32:37 +0200 | [diff] [blame] | 1349 | void (*reset)(struct drm_plane *plane); |
Rob Clark | 4d93914 | 2012-05-17 02:23:27 -0600 | [diff] [blame] | 1350 | |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1351 | /** |
| 1352 | * @set_property: |
| 1353 | * |
| 1354 | * This is the legacy entry point to update a property attached to the |
| 1355 | * plane. |
| 1356 | * |
| 1357 | * Drivers implementing atomic modeset should use |
| 1358 | * drm_atomic_helper_plane_set_property() to implement this hook. |
| 1359 | * |
| 1360 | * This callback is optional if the driver does not support any legacy |
| 1361 | * driver-private properties. |
| 1362 | * |
| 1363 | * RETURNS: |
| 1364 | * |
| 1365 | * 0 on success or a negative error code on failure. |
| 1366 | */ |
Rob Clark | 4d93914 | 2012-05-17 02:23:27 -0600 | [diff] [blame] | 1367 | int (*set_property)(struct drm_plane *plane, |
| 1368 | struct drm_property *property, uint64_t val); |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1369 | |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1370 | /** |
| 1371 | * @atomic_duplicate_state: |
| 1372 | * |
| 1373 | * Duplicate the current atomic state for this plane and return it. |
| 1374 | * The core and helpers gurantee that any atomic state duplicated with |
| 1375 | * this hook and still owned by the caller (i.e. not transferred to the |
| 1376 | * driver by calling ->atomic_commit() from struct |
| 1377 | * &drm_mode_config_funcs) will be cleaned up by calling the |
| 1378 | * @atomic_destroy_state hook in this structure. |
| 1379 | * |
| 1380 | * Atomic drivers which don't subclass struct &drm_plane_state should use |
| 1381 | * drm_atomic_helper_plane_duplicate_state(). Drivers that subclass the |
| 1382 | * state structure to extend it with driver-private state should use |
| 1383 | * __drm_atomic_helper_plane_duplicate_state() to make sure shared state is |
| 1384 | * duplicated in a consistent fashion across drivers. |
| 1385 | * |
| 1386 | * It is an error to call this hook before plane->state has been |
| 1387 | * initialized correctly. |
| 1388 | * |
| 1389 | * NOTE: |
| 1390 | * |
| 1391 | * If the duplicate state references refcounted resources this hook must |
| 1392 | * acquire a reference for each of them. The driver must release these |
| 1393 | * references again in @atomic_destroy_state. |
| 1394 | * |
| 1395 | * RETURNS: |
| 1396 | * |
| 1397 | * Duplicated atomic state or NULL when the allocation failed. |
| 1398 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1399 | struct drm_plane_state *(*atomic_duplicate_state)(struct drm_plane *plane); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1400 | |
| 1401 | /** |
| 1402 | * @atomic_destroy_state: |
| 1403 | * |
| 1404 | * Destroy a state duplicated with @atomic_duplicate_state and release |
| 1405 | * or unreference all resources it references |
| 1406 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1407 | void (*atomic_destroy_state)(struct drm_plane *plane, |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1408 | struct drm_plane_state *state); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1409 | |
| 1410 | /** |
| 1411 | * @atomic_set_property: |
| 1412 | * |
| 1413 | * Decode a driver-private property value and store the decoded value |
| 1414 | * into the passed-in state structure. Since the atomic core decodes all |
| 1415 | * standardized properties (even for extensions beyond the core set of |
| 1416 | * properties which might not be implemented by all drivers) this |
| 1417 | * requires drivers to subclass the state structure. |
| 1418 | * |
| 1419 | * Such driver-private properties should really only be implemented for |
| 1420 | * truly hardware/vendor specific state. Instead it is preferred to |
| 1421 | * standardize atomic extension and decode the properties used to expose |
| 1422 | * such an extension in the core. |
| 1423 | * |
| 1424 | * Do not call this function directly, use |
| 1425 | * drm_atomic_plane_set_property() instead. |
| 1426 | * |
| 1427 | * This callback is optional if the driver does not support any |
| 1428 | * driver-private atomic properties. |
| 1429 | * |
| 1430 | * NOTE: |
| 1431 | * |
| 1432 | * This function is called in the state assembly phase of atomic |
| 1433 | * modesets, which can be aborted for any reason (including on |
| 1434 | * userspace's request to just check whether a configuration would be |
| 1435 | * possible). Drivers MUST NOT touch any persistent state (hardware or |
| 1436 | * software) or data structures except the passed in @state parameter. |
| 1437 | * |
| 1438 | * Also since userspace controls in which order properties are set this |
| 1439 | * function must not do any input validation (since the state update is |
| 1440 | * incomplete and hence likely inconsistent). Instead any such input |
| 1441 | * validation must be done in the various atomic_check callbacks. |
| 1442 | * |
| 1443 | * RETURNS: |
| 1444 | * |
| 1445 | * 0 if the property has been found, -EINVAL if the property isn't |
| 1446 | * implemented by the driver (which shouldn't ever happen, the core only |
| 1447 | * asks for properties attached to this plane). No other validation is |
| 1448 | * allowed by the driver. The core already checks that the property |
| 1449 | * value is within the range (integer, valid enum value, ...) the driver |
| 1450 | * set when registering the property. |
| 1451 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1452 | int (*atomic_set_property)(struct drm_plane *plane, |
| 1453 | struct drm_plane_state *state, |
| 1454 | struct drm_property *property, |
| 1455 | uint64_t val); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1456 | |
| 1457 | /** |
| 1458 | * @atomic_get_property: |
| 1459 | * |
| 1460 | * Reads out the decoded driver-private property. This is used to |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 1461 | * implement the GETPLANE IOCTL. |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1462 | * |
| 1463 | * Do not call this function directly, use |
| 1464 | * drm_atomic_plane_get_property() instead. |
| 1465 | * |
| 1466 | * This callback is optional if the driver does not support any |
| 1467 | * driver-private atomic properties. |
| 1468 | * |
| 1469 | * RETURNS: |
| 1470 | * |
| 1471 | * 0 on success, -EINVAL if the property isn't implemented by the |
| 1472 | * driver (which should never happen, the core only asks for |
| 1473 | * properties attached to this plane). |
| 1474 | */ |
Rob Clark | ac9c925 | 2014-12-18 16:01:47 -0500 | [diff] [blame] | 1475 | int (*atomic_get_property)(struct drm_plane *plane, |
| 1476 | const struct drm_plane_state *state, |
| 1477 | struct drm_property *property, |
| 1478 | uint64_t *val); |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1479 | }; |
| 1480 | |
Matt Roper | e27dde3 | 2014-04-01 15:22:30 -0700 | [diff] [blame] | 1481 | enum drm_plane_type { |
| 1482 | DRM_PLANE_TYPE_OVERLAY, |
| 1483 | DRM_PLANE_TYPE_PRIMARY, |
| 1484 | DRM_PLANE_TYPE_CURSOR, |
| 1485 | }; |
| 1486 | |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1487 | |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1488 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 1489 | * struct drm_plane - central DRM plane control structure |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1490 | * @dev: DRM device this plane belongs to |
| 1491 | * @head: for list management |
| 1492 | * @base: base mode object |
| 1493 | * @possible_crtcs: pipes this plane can be bound to |
| 1494 | * @format_types: array of formats supported by this plane |
| 1495 | * @format_count: number of formats supported |
Laurent Pinchart | 7eb5f30 | 2015-03-09 10:41:07 +0200 | [diff] [blame] | 1496 | * @format_default: driver hasn't supplied supported formats for the plane |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1497 | * @crtc: currently bound CRTC |
| 1498 | * @fb: currently bound fb |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1499 | * @old_fb: Temporary tracking of the old fb while a modeset is ongoing. Used by |
| 1500 | * drm_mode_set_config_internal() to implement correct refcounting. |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1501 | * @funcs: helper functions |
Rob Clark | 4d93914 | 2012-05-17 02:23:27 -0600 | [diff] [blame] | 1502 | * @properties: property tracking for this plane |
Matt Roper | e27dde3 | 2014-04-01 15:22:30 -0700 | [diff] [blame] | 1503 | * @type: type of plane (overlay, primary, cursor) |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1504 | * @state: current atomic state for this plane |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1505 | */ |
| 1506 | struct drm_plane { |
| 1507 | struct drm_device *dev; |
| 1508 | struct list_head head; |
| 1509 | |
Ville Syrjälä | 9f4c97a | 2015-12-08 18:41:54 +0200 | [diff] [blame] | 1510 | char *name; |
| 1511 | |
Daniel Vetter | 4d02e2d | 2014-11-11 10:12:00 +0100 | [diff] [blame] | 1512 | struct drm_modeset_lock mutex; |
| 1513 | |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1514 | struct drm_mode_object base; |
| 1515 | |
| 1516 | uint32_t possible_crtcs; |
| 1517 | uint32_t *format_types; |
Thierry Reding | 45e3743 | 2015-08-12 16:54:28 +0200 | [diff] [blame] | 1518 | unsigned int format_count; |
Laurent Pinchart | 7eb5f30 | 2015-03-09 10:41:07 +0200 | [diff] [blame] | 1519 | bool format_default; |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1520 | |
| 1521 | struct drm_crtc *crtc; |
| 1522 | struct drm_framebuffer *fb; |
| 1523 | |
Daniel Vetter | 3d30a59 | 2014-07-27 13:42:42 +0200 | [diff] [blame] | 1524 | struct drm_framebuffer *old_fb; |
| 1525 | |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1526 | const struct drm_plane_funcs *funcs; |
Rob Clark | 4d93914 | 2012-05-17 02:23:27 -0600 | [diff] [blame] | 1527 | |
| 1528 | struct drm_object_properties properties; |
Matt Roper | e27dde3 | 2014-04-01 15:22:30 -0700 | [diff] [blame] | 1529 | |
| 1530 | enum drm_plane_type type; |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1531 | |
Daniel Vetter | 4490d4c | 2015-12-04 09:45:45 +0100 | [diff] [blame] | 1532 | const struct drm_plane_helper_funcs *helper_private; |
Daniel Vetter | c2fcd27 | 2014-11-05 00:14:14 +0100 | [diff] [blame] | 1533 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1534 | struct drm_plane_state *state; |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1535 | }; |
| 1536 | |
| 1537 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 1538 | * struct drm_bridge_funcs - drm_bridge control functions |
Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 1539 | * @attach: Called during drm_bridge_attach |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1540 | */ |
| 1541 | struct drm_bridge_funcs { |
Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 1542 | int (*attach)(struct drm_bridge *bridge); |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1543 | |
| 1544 | /** |
| 1545 | * @mode_fixup: |
| 1546 | * |
| 1547 | * This callback is used to validate and adjust a mode. The paramater |
| 1548 | * mode is the display mode that should be fed to the next element in |
| 1549 | * the display chain, either the final &drm_connector or the next |
| 1550 | * &drm_bridge. The parameter adjusted_mode is the input mode the bridge |
| 1551 | * requires. It can be modified by this callback and does not need to |
| 1552 | * match mode. |
| 1553 | * |
| 1554 | * This is the only hook that allows a bridge to reject a modeset. If |
| 1555 | * this function passes all other callbacks must succeed for this |
| 1556 | * configuration. |
| 1557 | * |
| 1558 | * NOTE: |
| 1559 | * |
| 1560 | * This function is called in the check phase of atomic modesets, which |
| 1561 | * can be aborted for any reason (including on userspace's request to |
| 1562 | * just check whether a configuration would be possible). Drivers MUST |
| 1563 | * NOT touch any persistent state (hardware or software) or data |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1564 | * structures except the passed in @state parameter. |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1565 | * |
| 1566 | * RETURNS: |
| 1567 | * |
| 1568 | * True if an acceptable configuration is possible, false if the modeset |
| 1569 | * operation should be rejected. |
| 1570 | */ |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1571 | bool (*mode_fixup)(struct drm_bridge *bridge, |
| 1572 | const struct drm_display_mode *mode, |
| 1573 | struct drm_display_mode *adjusted_mode); |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1574 | /** |
| 1575 | * @disable: |
| 1576 | * |
| 1577 | * This callback should disable the bridge. It is called right before |
| 1578 | * the preceding element in the display pipe is disabled. If the |
| 1579 | * preceding element is a bridge this means it's called before that |
| 1580 | * bridge's ->disable() function. If the preceding element is a |
| 1581 | * &drm_encoder it's called right before the encoder's ->disable(), |
| 1582 | * ->prepare() or ->dpms() hook from struct &drm_encoder_helper_funcs. |
| 1583 | * |
| 1584 | * The bridge can assume that the display pipe (i.e. clocks and timing |
| 1585 | * signals) feeding it is still running when this callback is called. |
| 1586 | */ |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1587 | void (*disable)(struct drm_bridge *bridge); |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1588 | |
| 1589 | /** |
| 1590 | * @post_disable: |
| 1591 | * |
| 1592 | * This callback should disable the bridge. It is called right after |
| 1593 | * the preceding element in the display pipe is disabled. If the |
| 1594 | * preceding element is a bridge this means it's called after that |
| 1595 | * bridge's ->post_disable() function. If the preceding element is a |
| 1596 | * &drm_encoder it's called right after the encoder's ->disable(), |
| 1597 | * ->prepare() or ->dpms() hook from struct &drm_encoder_helper_funcs. |
| 1598 | * |
| 1599 | * The bridge must assume that the display pipe (i.e. clocks and timing |
| 1600 | * singals) feeding it is no longer running when this callback is |
| 1601 | * called. |
| 1602 | */ |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1603 | void (*post_disable)(struct drm_bridge *bridge); |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1604 | |
| 1605 | /** |
| 1606 | * @mode_set: |
| 1607 | * |
| 1608 | * This callback should set the given mode on the bridge. It is called |
| 1609 | * after the ->mode_set() callback for the preceding element in the |
| 1610 | * display pipeline has been called already. The display pipe (i.e. |
| 1611 | * clocks and timing signals) is off when this function is called. |
| 1612 | */ |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1613 | void (*mode_set)(struct drm_bridge *bridge, |
| 1614 | struct drm_display_mode *mode, |
| 1615 | struct drm_display_mode *adjusted_mode); |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1616 | /** |
| 1617 | * @pre_enable: |
| 1618 | * |
| 1619 | * This callback should enable the bridge. It is called right before |
| 1620 | * the preceding element in the display pipe is enabled. If the |
| 1621 | * preceding element is a bridge this means it's called before that |
| 1622 | * bridge's ->pre_enable() function. If the preceding element is a |
| 1623 | * &drm_encoder it's called right before the encoder's ->enable(), |
| 1624 | * ->commit() or ->dpms() hook from struct &drm_encoder_helper_funcs. |
| 1625 | * |
| 1626 | * The display pipe (i.e. clocks and timing signals) feeding this bridge |
| 1627 | * will not yet be running when this callback is called. The bridge must |
| 1628 | * not enable the display link feeding the next bridge in the chain (if |
| 1629 | * there is one) when this callback is called. |
| 1630 | */ |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1631 | void (*pre_enable)(struct drm_bridge *bridge); |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1632 | |
| 1633 | /** |
| 1634 | * @enable: |
| 1635 | * |
| 1636 | * This callback should enable the bridge. It is called right after |
| 1637 | * the preceding element in the display pipe is enabled. If the |
| 1638 | * preceding element is a bridge this means it's called after that |
| 1639 | * bridge's ->enable() function. If the preceding element is a |
| 1640 | * &drm_encoder it's called right after the encoder's ->enable(), |
| 1641 | * ->commit() or ->dpms() hook from struct &drm_encoder_helper_funcs. |
| 1642 | * |
| 1643 | * The bridge can assume that the display pipe (i.e. clocks and timing |
| 1644 | * signals) feeding it is running when this callback is called. This |
| 1645 | * callback must enable the display link feeding the next bridge in the |
| 1646 | * chain if there is one. |
| 1647 | */ |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1648 | void (*enable)(struct drm_bridge *bridge); |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1649 | }; |
| 1650 | |
| 1651 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 1652 | * struct drm_bridge - central DRM bridge control structure |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1653 | * @dev: DRM device this bridge belongs to |
Archit Taneja | 862e686 | 2015-05-21 11:03:16 +0530 | [diff] [blame] | 1654 | * @encoder: encoder to which this bridge is connected |
| 1655 | * @next: the next bridge in the encoder chain |
Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 1656 | * @of_node: device node pointer to the bridge |
| 1657 | * @list: to keep track of all added bridges |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1658 | * @funcs: control functions |
| 1659 | * @driver_private: pointer to the bridge driver's internal context |
| 1660 | */ |
| 1661 | struct drm_bridge { |
| 1662 | struct drm_device *dev; |
Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 1663 | struct drm_encoder *encoder; |
Archit Taneja | 862e686 | 2015-05-21 11:03:16 +0530 | [diff] [blame] | 1664 | struct drm_bridge *next; |
Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 1665 | #ifdef CONFIG_OF |
| 1666 | struct device_node *of_node; |
| 1667 | #endif |
| 1668 | struct list_head list; |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1669 | |
| 1670 | const struct drm_bridge_funcs *funcs; |
| 1671 | void *driver_private; |
| 1672 | }; |
| 1673 | |
| 1674 | /** |
Rob Clark | 08855fa | 2015-03-11 10:23:09 -0400 | [diff] [blame] | 1675 | * struct drm_atomic_state - the global state object for atomic updates |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1676 | * @dev: parent DRM device |
Rob Clark | d34f20d | 2014-12-18 16:01:56 -0500 | [diff] [blame] | 1677 | * @allow_modeset: allow full modeset |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 1678 | * @legacy_cursor_update: hint to enforce legacy cursor IOCTL semantics |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1679 | * @planes: pointer to array of plane pointers |
| 1680 | * @plane_states: pointer to array of plane states pointers |
| 1681 | * @crtcs: pointer to array of CRTC pointers |
| 1682 | * @crtc_states: pointer to array of CRTC states pointers |
Daniel Vetter | f52b69f1 | 2014-11-19 18:38:08 +0100 | [diff] [blame] | 1683 | * @num_connector: size of the @connectors and @connector_states arrays |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1684 | * @connectors: pointer to array of connector pointers |
| 1685 | * @connector_states: pointer to array of connector states pointers |
| 1686 | * @acquire_ctx: acquire context for this atomic modeset state update |
| 1687 | */ |
| 1688 | struct drm_atomic_state { |
| 1689 | struct drm_device *dev; |
Rob Clark | d34f20d | 2014-12-18 16:01:56 -0500 | [diff] [blame] | 1690 | bool allow_modeset : 1; |
Daniel Vetter | f02ad90 | 2015-01-22 16:36:23 +0100 | [diff] [blame] | 1691 | bool legacy_cursor_update : 1; |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1692 | struct drm_plane **planes; |
| 1693 | struct drm_plane_state **plane_states; |
| 1694 | struct drm_crtc **crtcs; |
| 1695 | struct drm_crtc_state **crtc_states; |
Daniel Vetter | f52b69f1 | 2014-11-19 18:38:08 +0100 | [diff] [blame] | 1696 | int num_connector; |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1697 | struct drm_connector **connectors; |
| 1698 | struct drm_connector_state **connector_states; |
| 1699 | |
| 1700 | struct drm_modeset_acquire_ctx *acquire_ctx; |
| 1701 | }; |
| 1702 | |
| 1703 | |
| 1704 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 1705 | * struct drm_mode_set - new values for a CRTC config change |
Jesse Barnes | ef27351 | 2011-11-07 12:03:19 -0800 | [diff] [blame] | 1706 | * @fb: framebuffer to use for new config |
| 1707 | * @crtc: CRTC whose configuration we're about to change |
| 1708 | * @mode: mode timings to use |
| 1709 | * @x: position of this CRTC relative to @fb |
| 1710 | * @y: position of this CRTC relative to @fb |
| 1711 | * @connectors: array of connectors to drive with this CRTC if possible |
| 1712 | * @num_connectors: size of @connectors array |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1713 | * |
| 1714 | * Represents a single crtc the connectors that it drives with what mode |
| 1715 | * and from which framebuffer it scans out from. |
| 1716 | * |
| 1717 | * This is used to set modes. |
| 1718 | */ |
| 1719 | struct drm_mode_set { |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1720 | struct drm_framebuffer *fb; |
| 1721 | struct drm_crtc *crtc; |
| 1722 | struct drm_display_mode *mode; |
| 1723 | |
| 1724 | uint32_t x; |
| 1725 | uint32_t y; |
| 1726 | |
| 1727 | struct drm_connector **connectors; |
| 1728 | size_t num_connectors; |
| 1729 | }; |
| 1730 | |
| 1731 | /** |
Jesse Barnes | 550cebc | 2011-11-07 12:03:20 -0800 | [diff] [blame] | 1732 | * struct drm_mode_config_funcs - basic driver provided mode setting functions |
Jesse Barnes | 550cebc | 2011-11-07 12:03:20 -0800 | [diff] [blame] | 1733 | * |
| 1734 | * Some global (i.e. not per-CRTC, connector, etc) mode setting functions that |
| 1735 | * involve drivers. |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1736 | */ |
| 1737 | struct drm_mode_config_funcs { |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1738 | /** |
| 1739 | * @fb_create: |
| 1740 | * |
| 1741 | * Create a new framebuffer object. The core does basic checks on the |
| 1742 | * requested metadata, but most of that is left to the driver. See |
| 1743 | * struct &drm_mode_fb_cmd2 for details. |
| 1744 | * |
Daniel Vetter | d55f532 | 2015-12-08 09:49:19 +0100 | [diff] [blame] | 1745 | * If the parameters are deemed valid and the backing storage objects in |
| 1746 | * the underlying memory manager all exist, then the driver allocates |
| 1747 | * a new &drm_framebuffer structure, subclassed to contain |
| 1748 | * driver-specific information (like the internal native buffer object |
| 1749 | * references). It also needs to fill out all relevant metadata, which |
| 1750 | * should be done by calling drm_helper_mode_fill_fb_struct(). |
| 1751 | * |
| 1752 | * The initialization is finalized by calling drm_framebuffer_init(), |
| 1753 | * which registers the framebuffer and makes it accessible to other |
| 1754 | * threads. |
| 1755 | * |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1756 | * RETURNS: |
| 1757 | * |
| 1758 | * A new framebuffer with an initial reference count of 1 or a negative |
| 1759 | * error code encoded with ERR_PTR(). |
| 1760 | */ |
Jesse Barnes | 550cebc | 2011-11-07 12:03:20 -0800 | [diff] [blame] | 1761 | struct drm_framebuffer *(*fb_create)(struct drm_device *dev, |
| 1762 | struct drm_file *file_priv, |
Ville Syrjälä | 1eb8345 | 2015-11-11 19:11:29 +0200 | [diff] [blame] | 1763 | const struct drm_mode_fb_cmd2 *mode_cmd); |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1764 | |
| 1765 | /** |
| 1766 | * @output_poll_changed: |
| 1767 | * |
| 1768 | * Callback used by helpers to inform the driver of output configuration |
| 1769 | * changes. |
| 1770 | * |
| 1771 | * Drivers implementing fbdev emulation with the helpers can call |
| 1772 | * drm_fb_helper_hotplug_changed from this hook to inform the fbdev |
| 1773 | * helper of output changes. |
| 1774 | * |
| 1775 | * FIXME: |
| 1776 | * |
| 1777 | * Except that there's no vtable for device-level helper callbacks |
| 1778 | * there's no reason this is a core function. |
| 1779 | */ |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 1780 | void (*output_poll_changed)(struct drm_device *dev); |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1781 | |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1782 | /** |
| 1783 | * @atomic_check: |
| 1784 | * |
| 1785 | * This is the only hook to validate an atomic modeset update. This |
| 1786 | * function must reject any modeset and state changes which the hardware |
| 1787 | * or driver doesn't support. This includes but is of course not limited |
| 1788 | * to: |
| 1789 | * |
| 1790 | * - Checking that the modes, framebuffers, scaling and placement |
| 1791 | * requirements and so on are within the limits of the hardware. |
| 1792 | * |
| 1793 | * - Checking that any hidden shared resources are not oversubscribed. |
| 1794 | * This can be shared PLLs, shared lanes, overall memory bandwidth, |
| 1795 | * display fifo space (where shared between planes or maybe even |
| 1796 | * CRTCs). |
| 1797 | * |
| 1798 | * - Checking that virtualized resources exported to userspace are not |
| 1799 | * oversubscribed. For various reasons it can make sense to expose |
| 1800 | * more planes, crtcs or encoders than which are physically there. One |
| 1801 | * example is dual-pipe operations (which generally should be hidden |
| 1802 | * from userspace if when lockstepped in hardware, exposed otherwise), |
| 1803 | * where a plane might need 1 hardware plane (if it's just on one |
| 1804 | * pipe), 2 hardware planes (when it spans both pipes) or maybe even |
| 1805 | * shared a hardware plane with a 2nd plane (if there's a compatible |
| 1806 | * plane requested on the area handled by the other pipe). |
| 1807 | * |
| 1808 | * - Check that any transitional state is possible and that if |
| 1809 | * requested, the update can indeed be done in the vblank period |
| 1810 | * without temporarily disabling some functions. |
| 1811 | * |
| 1812 | * - Check any other constraints the driver or hardware might have. |
| 1813 | * |
| 1814 | * - This callback also needs to correctly fill out the &drm_crtc_state |
| 1815 | * in this update to make sure that drm_atomic_crtc_needs_modeset() |
| 1816 | * reflects the nature of the possible update and returns true if and |
| 1817 | * only if the update cannot be applied without tearing within one |
| 1818 | * vblank on that CRTC. The core uses that information to reject |
| 1819 | * updates which require a full modeset (i.e. blanking the screen, or |
| 1820 | * at least pausing updates for a substantial amount of time) if |
| 1821 | * userspace has disallowed that in its request. |
| 1822 | * |
| 1823 | * - The driver also does not need to repeat basic input validation |
| 1824 | * like done for the corresponding legacy entry points. The core does |
| 1825 | * that before calling this hook. |
| 1826 | * |
| 1827 | * See the documentation of @atomic_commit for an exhaustive list of |
| 1828 | * error conditions which don't have to be checked at the |
| 1829 | * ->atomic_check() stage? |
| 1830 | * |
| 1831 | * See the documentation for struct &drm_atomic_state for how exactly |
| 1832 | * an atomic modeset update is described. |
| 1833 | * |
| 1834 | * Drivers using the atomic helpers can implement this hook using |
| 1835 | * drm_atomic_helper_check(), or one of the exported sub-functions of |
| 1836 | * it. |
| 1837 | * |
| 1838 | * RETURNS: |
| 1839 | * |
| 1840 | * 0 on success or one of the below negative error codes: |
| 1841 | * |
| 1842 | * - -EINVAL, if any of the above constraints are violated. |
| 1843 | * |
| 1844 | * - -EDEADLK, when returned from an attempt to acquire an additional |
| 1845 | * &drm_modeset_lock through drm_modeset_lock(). |
| 1846 | * |
| 1847 | * - -ENOMEM, if allocating additional state sub-structures failed due |
| 1848 | * to lack of memory. |
| 1849 | * |
| 1850 | * - -EINTR, -EAGAIN or -ERESTARTSYS, if the IOCTL should be restarted. |
| 1851 | * This can either be due to a pending signal, or because the driver |
| 1852 | * needs to completely bail out to recover from an exceptional |
| 1853 | * situation like a GPU hang. From a userspace point all errors are |
| 1854 | * treated equally. |
| 1855 | */ |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1856 | int (*atomic_check)(struct drm_device *dev, |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1857 | struct drm_atomic_state *state); |
| 1858 | |
| 1859 | /** |
| 1860 | * @atomic_commit: |
| 1861 | * |
| 1862 | * This is the only hook to commit an atomic modeset update. The core |
| 1863 | * guarantees that @atomic_check has been called successfully before |
| 1864 | * calling this function, and that nothing has been changed in the |
| 1865 | * interim. |
| 1866 | * |
| 1867 | * See the documentation for struct &drm_atomic_state for how exactly |
| 1868 | * an atomic modeset update is described. |
| 1869 | * |
| 1870 | * Drivers using the atomic helpers can implement this hook using |
| 1871 | * drm_atomic_helper_commit(), or one of the exported sub-functions of |
| 1872 | * it. |
| 1873 | * |
| 1874 | * Asynchronous commits (as indicated with the async parameter) must |
| 1875 | * do any preparatory work which might result in an unsuccessful commit |
| 1876 | * in the context of this callback. The only exceptions are hardware |
| 1877 | * errors resulting in -EIO. But even in that case the driver must |
| 1878 | * ensure that the display pipe is at least running, to avoid |
| 1879 | * compositors crashing when pageflips don't work. Anything else, |
| 1880 | * specifically committing the update to the hardware, should be done |
| 1881 | * without blocking the caller. For updates which do not require a |
| 1882 | * modeset this must be guaranteed. |
| 1883 | * |
| 1884 | * The driver must wait for any pending rendering to the new |
| 1885 | * framebuffers to complete before executing the flip. It should also |
| 1886 | * wait for any pending rendering from other drivers if the underlying |
| 1887 | * buffer is a shared dma-buf. Asynchronous commits must not wait for |
| 1888 | * rendering in the context of this callback. |
| 1889 | * |
| 1890 | * An application can request to be notified when the atomic commit has |
| 1891 | * completed. These events are per-CRTC and can be distinguished by the |
| 1892 | * CRTC index supplied in &drm_event to userspace. |
| 1893 | * |
| 1894 | * The drm core will supply a struct &drm_event in the event |
| 1895 | * member of each CRTC's &drm_crtc_state structure. This can be handled by the |
| 1896 | * drm_crtc_send_vblank_event() function, which the driver should call on |
| 1897 | * the provided event upon completion of the atomic commit. Note that if |
| 1898 | * the driver supports vblank signalling and timestamping the vblank |
| 1899 | * counters and timestamps must agree with the ones returned from page |
| 1900 | * flip events. With the current vblank helper infrastructure this can |
| 1901 | * be achieved by holding a vblank reference while the page flip is |
| 1902 | * pending, acquired through drm_crtc_vblank_get() and released with |
| 1903 | * drm_crtc_vblank_put(). Drivers are free to implement their own vblank |
| 1904 | * counter and timestamp tracking though, e.g. if they have accurate |
| 1905 | * timestamp registers in hardware. |
| 1906 | * |
| 1907 | * NOTE: |
| 1908 | * |
| 1909 | * Drivers are not allowed to shut down any display pipe successfully |
| 1910 | * enabled through an atomic commit on their own. Doing so can result in |
| 1911 | * compositors crashing if a page flip is suddenly rejected because the |
| 1912 | * pipe is off. |
| 1913 | * |
| 1914 | * RETURNS: |
| 1915 | * |
| 1916 | * 0 on success or one of the below negative error codes: |
| 1917 | * |
| 1918 | * - -EBUSY, if an asynchronous updated is requested and there is |
| 1919 | * an earlier updated pending. Drivers are allowed to support a queue |
| 1920 | * of outstanding updates, but currently no driver supports that. |
| 1921 | * Note that drivers must wait for preceding updates to complete if a |
| 1922 | * synchronous update is requested, they are not allowed to fail the |
| 1923 | * commit in that case. |
| 1924 | * |
| 1925 | * - -ENOMEM, if the driver failed to allocate memory. Specifically |
| 1926 | * this can happen when trying to pin framebuffers, which must only |
| 1927 | * be done when committing the state. |
| 1928 | * |
| 1929 | * - -ENOSPC, as a refinement of the more generic -ENOMEM to indicate |
| 1930 | * that the driver has run out of vram, iommu space or similar GPU |
| 1931 | * address space needed for framebuffer. |
| 1932 | * |
| 1933 | * - -EIO, if the hardware completely died. |
| 1934 | * |
| 1935 | * - -EINTR, -EAGAIN or -ERESTARTSYS, if the IOCTL should be restarted. |
| 1936 | * This can either be due to a pending signal, or because the driver |
| 1937 | * needs to completely bail out to recover from an exceptional |
| 1938 | * situation like a GPU hang. From a userspace point of view all errors are |
| 1939 | * treated equally. |
| 1940 | * |
| 1941 | * This list is exhaustive. Specifically this hook is not allowed to |
| 1942 | * return -EINVAL (any invalid requests should be caught in |
| 1943 | * @atomic_check) or -EDEADLK (this function must not acquire |
| 1944 | * additional modeset locks). |
| 1945 | */ |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1946 | int (*atomic_commit)(struct drm_device *dev, |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1947 | struct drm_atomic_state *state, |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1948 | bool async); |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1949 | |
| 1950 | /** |
| 1951 | * @atomic_state_alloc: |
| 1952 | * |
| 1953 | * This optional hook can be used by drivers that want to subclass struct |
| 1954 | * &drm_atomic_state to be able to track their own driver-private global |
| 1955 | * state easily. If this hook is implemented, drivers must also |
| 1956 | * implement @atomic_state_clear and @atomic_state_free. |
| 1957 | * |
| 1958 | * RETURNS: |
| 1959 | * |
| 1960 | * A new &drm_atomic_state on success or NULL on failure. |
| 1961 | */ |
Maarten Lankhorst | 036ef57 | 2015-05-18 10:06:40 +0200 | [diff] [blame] | 1962 | struct drm_atomic_state *(*atomic_state_alloc)(struct drm_device *dev); |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1963 | |
| 1964 | /** |
| 1965 | * @atomic_state_clear: |
| 1966 | * |
| 1967 | * This hook must clear any driver private state duplicated into the |
| 1968 | * passed-in &drm_atomic_state. This hook is called when the caller |
| 1969 | * encountered a &drm_modeset_lock deadlock and needs to drop all |
| 1970 | * already acquired locks as part of the deadlock avoidance dance |
| 1971 | * implemented in drm_modeset_lock_backoff(). |
| 1972 | * |
| 1973 | * Any duplicated state must be invalidated since a concurrent atomic |
| 1974 | * update might change it, and the drm atomic interfaces always apply |
| 1975 | * updates as relative changes to the current state. |
| 1976 | * |
| 1977 | * Drivers that implement this must call drm_atomic_state_default_clear() |
| 1978 | * to clear common state. |
| 1979 | */ |
Maarten Lankhorst | 036ef57 | 2015-05-18 10:06:40 +0200 | [diff] [blame] | 1980 | void (*atomic_state_clear)(struct drm_atomic_state *state); |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 1981 | |
| 1982 | /** |
| 1983 | * @atomic_state_free: |
| 1984 | * |
| 1985 | * This hook needs driver private resources and the &drm_atomic_state |
| 1986 | * itself. Note that the core first calls drm_atomic_state_clear() to |
| 1987 | * avoid code duplicate between the clear and free hooks. |
| 1988 | * |
| 1989 | * Drivers that implement this must call drm_atomic_state_default_free() |
| 1990 | * to release common resources. |
| 1991 | */ |
Maarten Lankhorst | 036ef57 | 2015-05-18 10:06:40 +0200 | [diff] [blame] | 1992 | void (*atomic_state_free)(struct drm_atomic_state *state); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1993 | }; |
| 1994 | |
Jesse Barnes | c1aaca2 | 2011-11-07 12:03:21 -0800 | [diff] [blame] | 1995 | /** |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1996 | * struct drm_mode_config - Mode configuration control structure |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 1997 | * @mutex: mutex protecting KMS related lists and structures |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1998 | * @connection_mutex: ww mutex protecting connector state and routing |
| 1999 | * @acquire_ctx: global implicit acquire context used by atomic drivers for |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 2000 | * legacy IOCTLs |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 2001 | * @idr_mutex: mutex for KMS ID allocation and management |
| 2002 | * @crtc_idr: main KMS ID tracking object |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 2003 | * @fb_lock: mutex to protect fb state and lists |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 2004 | * @num_fb: number of fbs available |
| 2005 | * @fb_list: list of framebuffers available |
| 2006 | * @num_connector: number of connectors on this device |
| 2007 | * @connector_list: list of connector objects |
| 2008 | * @num_encoder: number of encoders on this device |
| 2009 | * @encoder_list: list of encoder objects |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 2010 | * @num_overlay_plane: number of overlay planes on this device |
| 2011 | * @num_total_plane: number of universal (i.e. with primary/curso) planes on this device |
| 2012 | * @plane_list: list of plane objects |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 2013 | * @num_crtc: number of CRTCs on this device |
| 2014 | * @crtc_list: list of CRTC objects |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 2015 | * @property_list: list of property objects |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 2016 | * @min_width: minimum pixel width on this device |
| 2017 | * @min_height: minimum pixel height on this device |
| 2018 | * @max_width: maximum pixel width on this device |
| 2019 | * @max_height: maximum pixel height on this device |
| 2020 | * @funcs: core driver provided mode setting functions |
| 2021 | * @fb_base: base address of the framebuffer |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 2022 | * @poll_enabled: track polling support for this device |
| 2023 | * @poll_running: track polling status for this device |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 2024 | * @output_poll_work: delayed work for polling in process context |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 2025 | * @property_blob_list: list of all the blob property objects |
Daniel Stone | 8fb6e7a | 2015-04-20 19:22:54 +0100 | [diff] [blame] | 2026 | * @blob_lock: mutex for blob property allocation and management |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 2027 | * @*_property: core property tracking |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 2028 | * @preferred_depth: preferred RBG pixel depth, used by fb helpers |
| 2029 | * @prefer_shadow: hint to userspace to prefer shadow-fb rendering |
| 2030 | * @async_page_flip: does this device support async flips on the primary plane? |
| 2031 | * @cursor_width: hint to userspace for max cursor width |
| 2032 | * @cursor_height: hint to userspace for max cursor height |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2033 | * |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 2034 | * Core mode resource tracking structure. All CRTC, encoders, and connectors |
| 2035 | * enumerated by the driver are added here, as are global properties. Some |
| 2036 | * global restrictions are also here, e.g. dimension restrictions. |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2037 | */ |
| 2038 | struct drm_mode_config { |
Jesse Barnes | ad2563c | 2009-01-19 17:21:45 +1000 | [diff] [blame] | 2039 | struct mutex mutex; /* protects configuration (mode lists etc.) */ |
Rob Clark | 51fd371 | 2013-11-19 12:10:12 -0500 | [diff] [blame] | 2040 | struct drm_modeset_lock connection_mutex; /* protects connector->encoder and encoder->crtc links */ |
| 2041 | struct drm_modeset_acquire_ctx *acquire_ctx; /* for legacy _lock_all() / _unlock_all() */ |
Jesse Barnes | ad2563c | 2009-01-19 17:21:45 +1000 | [diff] [blame] | 2042 | struct mutex idr_mutex; /* for IDR management */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2043 | struct idr crtc_idr; /* use this idr for all IDs, fb, crtc, connector, modes - just makes life easier */ |
Dave Airlie | 138f9eb | 2014-10-20 16:17:17 +1000 | [diff] [blame] | 2044 | struct idr tile_idr; /* use this idr for all IDs, fb, crtc, connector, modes - just makes life easier */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2045 | /* this is limited to one for now */ |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 2046 | |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 2047 | struct mutex fb_lock; /* proctects global and per-file fb lists */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2048 | int num_fb; |
| 2049 | struct list_head fb_list; |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 2050 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2051 | int num_connector; |
| 2052 | struct list_head connector_list; |
| 2053 | int num_encoder; |
| 2054 | struct list_head encoder_list; |
Matt Roper | e27dde3 | 2014-04-01 15:22:30 -0700 | [diff] [blame] | 2055 | |
| 2056 | /* |
| 2057 | * Track # of overlay planes separately from # of total planes. By |
| 2058 | * default we only advertise overlay planes to userspace; if userspace |
| 2059 | * sets the "universal plane" capability bit, we'll go ahead and |
| 2060 | * expose all planes. |
| 2061 | */ |
| 2062 | int num_overlay_plane; |
| 2063 | int num_total_plane; |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 2064 | struct list_head plane_list; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2065 | |
| 2066 | int num_crtc; |
| 2067 | struct list_head crtc_list; |
| 2068 | |
| 2069 | struct list_head property_list; |
| 2070 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2071 | int min_width, min_height; |
| 2072 | int max_width, max_height; |
Laurent Pinchart | e6ecefa | 2012-05-17 13:27:23 +0200 | [diff] [blame] | 2073 | const struct drm_mode_config_funcs *funcs; |
Benjamin Herrenschmidt | d883f7f | 2009-02-02 16:55:45 +1100 | [diff] [blame] | 2074 | resource_size_t fb_base; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2075 | |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 2076 | /* output poll support */ |
| 2077 | bool poll_enabled; |
Daniel Vetter | 905bc9f | 2012-10-23 18:23:36 +0000 | [diff] [blame] | 2078 | bool poll_running; |
Daniel Vetter | 162b6a5 | 2015-01-21 08:45:21 +0100 | [diff] [blame] | 2079 | bool delayed_event; |
Tejun Heo | 991ea75 | 2010-07-20 22:09:02 +0200 | [diff] [blame] | 2080 | struct delayed_work output_poll_work; |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 2081 | |
Daniel Stone | 8fb6e7a | 2015-04-20 19:22:54 +0100 | [diff] [blame] | 2082 | struct mutex blob_lock; |
| 2083 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2084 | /* pointers to standard properties */ |
| 2085 | struct list_head property_blob_list; |
| 2086 | struct drm_property *edid_property; |
| 2087 | struct drm_property *dpms_property; |
Dave Airlie | 43aba7e | 2014-06-05 14:01:31 +1000 | [diff] [blame] | 2088 | struct drm_property *path_property; |
Dave Airlie | 6f134d7 | 2014-10-20 16:30:50 +1000 | [diff] [blame] | 2089 | struct drm_property *tile_property; |
Rob Clark | 9922ab5 | 2014-04-01 20:16:57 -0400 | [diff] [blame] | 2090 | struct drm_property *plane_type_property; |
Sonika Jindal | 2a297cc | 2014-08-05 11:26:54 +0530 | [diff] [blame] | 2091 | struct drm_property *rotation_property; |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 2092 | struct drm_property *prop_src_x; |
| 2093 | struct drm_property *prop_src_y; |
| 2094 | struct drm_property *prop_src_w; |
| 2095 | struct drm_property *prop_src_h; |
| 2096 | struct drm_property *prop_crtc_x; |
| 2097 | struct drm_property *prop_crtc_y; |
| 2098 | struct drm_property *prop_crtc_w; |
| 2099 | struct drm_property *prop_crtc_h; |
| 2100 | struct drm_property *prop_fb_id; |
| 2101 | struct drm_property *prop_crtc_id; |
Daniel Vetter | eab3bbe | 2015-01-22 16:36:21 +0100 | [diff] [blame] | 2102 | struct drm_property *prop_active; |
Daniel Stone | 955f3c3 | 2015-05-25 19:11:52 +0100 | [diff] [blame] | 2103 | struct drm_property *prop_mode_id; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2104 | |
| 2105 | /* DVI-I properties */ |
| 2106 | struct drm_property *dvi_i_subconnector_property; |
| 2107 | struct drm_property *dvi_i_select_subconnector_property; |
| 2108 | |
| 2109 | /* TV properties */ |
| 2110 | struct drm_property *tv_subconnector_property; |
| 2111 | struct drm_property *tv_select_subconnector_property; |
| 2112 | struct drm_property *tv_mode_property; |
| 2113 | struct drm_property *tv_left_margin_property; |
| 2114 | struct drm_property *tv_right_margin_property; |
| 2115 | struct drm_property *tv_top_margin_property; |
| 2116 | struct drm_property *tv_bottom_margin_property; |
Francisco Jerez | b6b7902 | 2009-08-02 04:19:20 +0200 | [diff] [blame] | 2117 | struct drm_property *tv_brightness_property; |
| 2118 | struct drm_property *tv_contrast_property; |
| 2119 | struct drm_property *tv_flicker_reduction_property; |
Francisco Jerez | a75f023 | 2009-08-12 02:30:10 +0200 | [diff] [blame] | 2120 | struct drm_property *tv_overscan_property; |
| 2121 | struct drm_property *tv_saturation_property; |
| 2122 | struct drm_property *tv_hue_property; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2123 | |
| 2124 | /* Optional properties */ |
| 2125 | struct drm_property *scaling_mode_property; |
Vandana Kannan | ff587e4 | 2014-06-11 10:46:48 +0530 | [diff] [blame] | 2126 | struct drm_property *aspect_ratio_property; |
Jakob Bornecrantz | 884840a | 2009-12-03 23:25:47 +0000 | [diff] [blame] | 2127 | struct drm_property *dirty_info_property; |
Dave Airlie | 019d96c | 2011-09-29 16:20:42 +0100 | [diff] [blame] | 2128 | |
Dave Airlie | 5bb2bbf | 2014-11-10 10:18:15 +1000 | [diff] [blame] | 2129 | /* properties for virtual machine layout */ |
| 2130 | struct drm_property *suggested_x_property; |
| 2131 | struct drm_property *suggested_y_property; |
| 2132 | |
Dave Airlie | 019d96c | 2011-09-29 16:20:42 +0100 | [diff] [blame] | 2133 | /* dumb ioctl parameters */ |
| 2134 | uint32_t preferred_depth, prefer_shadow; |
Keith Packard | 62f2104 | 2013-07-22 18:50:00 -0700 | [diff] [blame] | 2135 | |
| 2136 | /* whether async page flip is supported or not */ |
| 2137 | bool async_page_flip; |
Alex Deucher | 8716ed4 | 2014-02-12 12:48:23 -0500 | [diff] [blame] | 2138 | |
Rob Clark | e3eb325 | 2015-02-05 14:41:52 +0000 | [diff] [blame] | 2139 | /* whether the driver supports fb modifiers */ |
| 2140 | bool allow_fb_modifiers; |
| 2141 | |
Alex Deucher | 8716ed4 | 2014-02-12 12:48:23 -0500 | [diff] [blame] | 2142 | /* cursor size */ |
| 2143 | uint32_t cursor_width, cursor_height; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2144 | }; |
| 2145 | |
Rob Clark | dd27595 | 2014-11-25 20:29:46 -0500 | [diff] [blame] | 2146 | /** |
| 2147 | * drm_for_each_plane_mask - iterate over planes specified by bitmask |
| 2148 | * @plane: the loop cursor |
| 2149 | * @dev: the DRM device |
| 2150 | * @plane_mask: bitmask of plane indices |
| 2151 | * |
| 2152 | * Iterate over all planes specified by bitmask. |
| 2153 | */ |
| 2154 | #define drm_for_each_plane_mask(plane, dev, plane_mask) \ |
| 2155 | list_for_each_entry((plane), &(dev)->mode_config.plane_list, head) \ |
Jani Nikula | 373701b | 2015-11-24 21:21:55 +0200 | [diff] [blame] | 2156 | for_each_if ((plane_mask) & (1 << drm_plane_index(plane))) |
Rob Clark | dd27595 | 2014-11-25 20:29:46 -0500 | [diff] [blame] | 2157 | |
Maarten Lankhorst | ead8b66 | 2016-01-07 10:59:19 +0100 | [diff] [blame] | 2158 | /** |
| 2159 | * drm_for_each_encoder_mask - iterate over encoders specified by bitmask |
| 2160 | * @encoder: the loop cursor |
| 2161 | * @dev: the DRM device |
| 2162 | * @encoder_mask: bitmask of encoder indices |
| 2163 | * |
| 2164 | * Iterate over all encoders specified by bitmask. |
| 2165 | */ |
| 2166 | #define drm_for_each_encoder_mask(encoder, dev, encoder_mask) \ |
| 2167 | list_for_each_entry((encoder), &(dev)->mode_config.encoder_list, head) \ |
| 2168 | for_each_if ((encoder_mask) & (1 << drm_encoder_index(encoder))) |
Rob Clark | dd27595 | 2014-11-25 20:29:46 -0500 | [diff] [blame] | 2169 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2170 | #define obj_to_crtc(x) container_of(x, struct drm_crtc, base) |
| 2171 | #define obj_to_connector(x) container_of(x, struct drm_connector, base) |
| 2172 | #define obj_to_encoder(x) container_of(x, struct drm_encoder, base) |
| 2173 | #define obj_to_mode(x) container_of(x, struct drm_display_mode, base) |
| 2174 | #define obj_to_fb(x) container_of(x, struct drm_framebuffer, base) |
| 2175 | #define obj_to_property(x) container_of(x, struct drm_property, base) |
| 2176 | #define obj_to_blob(x) container_of(x, struct drm_property_blob, base) |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 2177 | #define obj_to_plane(x) container_of(x, struct drm_plane, base) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2178 | |
Sascha Hauer | 4a67d39 | 2012-02-06 10:58:17 +0100 | [diff] [blame] | 2179 | struct drm_prop_enum_list { |
| 2180 | int type; |
| 2181 | char *name; |
| 2182 | }; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2183 | |
Ville Syrjälä | f988287 | 2015-12-09 16:19:31 +0200 | [diff] [blame] | 2184 | extern __printf(6, 7) |
| 2185 | int drm_crtc_init_with_planes(struct drm_device *dev, |
| 2186 | struct drm_crtc *crtc, |
| 2187 | struct drm_plane *primary, |
| 2188 | struct drm_plane *cursor, |
| 2189 | const struct drm_crtc_funcs *funcs, |
| 2190 | const char *name, ...); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2191 | extern void drm_crtc_cleanup(struct drm_crtc *crtc); |
Russell King | db5f7a6 | 2014-01-02 21:27:33 +0000 | [diff] [blame] | 2192 | extern unsigned int drm_crtc_index(struct drm_crtc *crtc); |
| 2193 | |
| 2194 | /** |
| 2195 | * drm_crtc_mask - find the mask of a registered CRTC |
| 2196 | * @crtc: CRTC to find mask for |
| 2197 | * |
| 2198 | * Given a registered CRTC, return the mask bit of that CRTC for an |
| 2199 | * encoder's possible_crtcs field. |
| 2200 | */ |
| 2201 | static inline uint32_t drm_crtc_mask(struct drm_crtc *crtc) |
| 2202 | { |
| 2203 | return 1 << drm_crtc_index(crtc); |
| 2204 | } |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2205 | |
Ilia Mirkin | b21e3af | 2013-08-07 22:34:48 -0400 | [diff] [blame] | 2206 | extern void drm_connector_ida_init(void); |
| 2207 | extern void drm_connector_ida_destroy(void); |
Ville Syrjälä | 6bfc56a | 2012-03-13 12:35:48 +0200 | [diff] [blame] | 2208 | extern int drm_connector_init(struct drm_device *dev, |
| 2209 | struct drm_connector *connector, |
| 2210 | const struct drm_connector_funcs *funcs, |
| 2211 | int connector_type); |
Thomas Wood | 34ea3d3 | 2014-05-29 16:57:41 +0100 | [diff] [blame] | 2212 | int drm_connector_register(struct drm_connector *connector); |
| 2213 | void drm_connector_unregister(struct drm_connector *connector); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2214 | |
| 2215 | extern void drm_connector_cleanup(struct drm_connector *connector); |
Daniel Vetter | 10f637b | 2014-07-29 13:47:11 +0200 | [diff] [blame] | 2216 | extern unsigned int drm_connector_index(struct drm_connector *connector); |
Dave Airlie | cbc7e22 | 2012-02-20 14:16:40 +0000 | [diff] [blame] | 2217 | /* helper to unplug all connectors from sysfs for device */ |
| 2218 | extern void drm_connector_unplug_all(struct drm_device *dev); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2219 | |
Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 2220 | extern int drm_bridge_add(struct drm_bridge *bridge); |
| 2221 | extern void drm_bridge_remove(struct drm_bridge *bridge); |
| 2222 | extern struct drm_bridge *of_drm_find_bridge(struct device_node *np); |
| 2223 | extern int drm_bridge_attach(struct drm_device *dev, struct drm_bridge *bridge); |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 2224 | |
Archit Taneja | 862e686 | 2015-05-21 11:03:16 +0530 | [diff] [blame] | 2225 | bool drm_bridge_mode_fixup(struct drm_bridge *bridge, |
| 2226 | const struct drm_display_mode *mode, |
| 2227 | struct drm_display_mode *adjusted_mode); |
| 2228 | void drm_bridge_disable(struct drm_bridge *bridge); |
| 2229 | void drm_bridge_post_disable(struct drm_bridge *bridge); |
| 2230 | void drm_bridge_mode_set(struct drm_bridge *bridge, |
| 2231 | struct drm_display_mode *mode, |
| 2232 | struct drm_display_mode *adjusted_mode); |
| 2233 | void drm_bridge_pre_enable(struct drm_bridge *bridge); |
| 2234 | void drm_bridge_enable(struct drm_bridge *bridge); |
| 2235 | |
Ville Syrjälä | 13a3d91 | 2015-12-09 16:20:18 +0200 | [diff] [blame] | 2236 | extern __printf(5, 6) |
| 2237 | int drm_encoder_init(struct drm_device *dev, |
| 2238 | struct drm_encoder *encoder, |
| 2239 | const struct drm_encoder_funcs *funcs, |
| 2240 | int encoder_type, const char *name, ...); |
Maarten Lankhorst | 47d7777 | 2016-01-07 10:59:18 +0100 | [diff] [blame] | 2241 | extern unsigned int drm_encoder_index(struct drm_encoder *encoder); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2242 | |
Thierry Reding | 3d88736 | 2014-01-13 14:33:20 +0100 | [diff] [blame] | 2243 | /** |
| 2244 | * drm_encoder_crtc_ok - can a given crtc drive a given encoder? |
| 2245 | * @encoder: encoder to test |
| 2246 | * @crtc: crtc to test |
| 2247 | * |
| 2248 | * Return false if @encoder can't be driven by @crtc, true otherwise. |
| 2249 | */ |
| 2250 | static inline bool drm_encoder_crtc_ok(struct drm_encoder *encoder, |
| 2251 | struct drm_crtc *crtc) |
| 2252 | { |
| 2253 | return !!(encoder->possible_crtcs & drm_crtc_mask(crtc)); |
| 2254 | } |
| 2255 | |
Ville Syrjälä | b0b3b79 | 2015-12-09 16:19:55 +0200 | [diff] [blame] | 2256 | extern __printf(8, 9) |
| 2257 | int drm_universal_plane_init(struct drm_device *dev, |
| 2258 | struct drm_plane *plane, |
| 2259 | unsigned long possible_crtcs, |
| 2260 | const struct drm_plane_funcs *funcs, |
| 2261 | const uint32_t *formats, |
| 2262 | unsigned int format_count, |
| 2263 | enum drm_plane_type type, |
| 2264 | const char *name, ...); |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 2265 | extern int drm_plane_init(struct drm_device *dev, |
| 2266 | struct drm_plane *plane, |
| 2267 | unsigned long possible_crtcs, |
| 2268 | const struct drm_plane_funcs *funcs, |
Thierry Reding | 45e3743 | 2015-08-12 16:54:28 +0200 | [diff] [blame] | 2269 | const uint32_t *formats, unsigned int format_count, |
Matt Roper | dc415ff | 2014-04-01 15:22:36 -0700 | [diff] [blame] | 2270 | bool is_primary); |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 2271 | extern void drm_plane_cleanup(struct drm_plane *plane); |
Daniel Vetter | 10f637b | 2014-07-29 13:47:11 +0200 | [diff] [blame] | 2272 | extern unsigned int drm_plane_index(struct drm_plane *plane); |
Chandra Konduru | f81338a | 2015-04-09 17:36:21 -0700 | [diff] [blame] | 2273 | 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] | 2274 | extern void drm_plane_force_disable(struct drm_plane *plane); |
Laurent Pinchart | ead8610 | 2015-03-05 02:25:43 +0200 | [diff] [blame] | 2275 | extern int drm_plane_check_pixel_format(const struct drm_plane *plane, |
| 2276 | u32 format); |
Gustavo Padovan | ecb7e16 | 2014-12-01 15:40:09 -0800 | [diff] [blame] | 2277 | extern void drm_crtc_get_hv_timing(const struct drm_display_mode *mode, |
| 2278 | int *hdisplay, int *vdisplay); |
Matt Roper | af93629 | 2014-04-01 15:22:34 -0700 | [diff] [blame] | 2279 | extern int drm_crtc_check_viewport(const struct drm_crtc *crtc, |
| 2280 | int x, int y, |
| 2281 | const struct drm_display_mode *mode, |
| 2282 | const struct drm_framebuffer *fb); |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 2283 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2284 | extern void drm_encoder_cleanup(struct drm_encoder *encoder); |
| 2285 | |
Ville Syrjälä | d20d317 | 2013-06-07 15:43:07 +0000 | [diff] [blame] | 2286 | extern const char *drm_get_connector_status_name(enum drm_connector_status status); |
Jesse Barnes | ac1bb36 | 2014-02-10 15:32:44 -0800 | [diff] [blame] | 2287 | extern const char *drm_get_subpixel_order_name(enum subpixel_order order); |
Ville Syrjälä | d20d317 | 2013-06-07 15:43:07 +0000 | [diff] [blame] | 2288 | extern const char *drm_get_dpms_name(int val); |
| 2289 | extern const char *drm_get_dvi_i_subconnector_name(int val); |
| 2290 | extern const char *drm_get_dvi_i_select_name(int val); |
| 2291 | extern const char *drm_get_tv_subconnector_name(int val); |
| 2292 | extern const char *drm_get_tv_select_name(int val); |
Kristian Høgsberg | ea39f83 | 2009-02-12 14:37:56 -0500 | [diff] [blame] | 2293 | extern void drm_fb_release(struct drm_file *file_priv); |
Daniel Stone | e2f5d2e | 2015-05-22 13:34:51 +0100 | [diff] [blame] | 2294 | extern void drm_property_destroy_user_blobs(struct drm_device *dev, |
| 2295 | struct drm_file *file_priv); |
Adam Jackson | fbff469 | 2012-09-18 10:58:47 -0400 | [diff] [blame] | 2296 | extern bool drm_probe_ddc(struct i2c_adapter *adapter); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2297 | extern struct edid *drm_get_edid(struct drm_connector *connector, |
| 2298 | struct i2c_adapter *adapter); |
Lukas Wunner | 5cb8eaa2 | 2016-01-11 20:09:20 +0100 | [diff] [blame] | 2299 | extern struct edid *drm_get_edid_switcheroo(struct drm_connector *connector, |
| 2300 | struct i2c_adapter *adapter); |
Jani Nikula | 51f8da5 | 2013-09-27 15:08:27 +0300 | [diff] [blame] | 2301 | extern struct edid *drm_edid_duplicate(const struct edid *edid); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2302 | extern int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2303 | extern void drm_mode_config_init(struct drm_device *dev); |
Chris Wilson | eb03355 | 2011-01-24 15:11:08 +0000 | [diff] [blame] | 2304 | extern void drm_mode_config_reset(struct drm_device *dev); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2305 | extern void drm_mode_config_cleanup(struct drm_device *dev); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2306 | |
Dave Airlie | 43aba7e | 2014-06-05 14:01:31 +1000 | [diff] [blame] | 2307 | extern int drm_mode_connector_set_path_property(struct drm_connector *connector, |
Thierry Reding | 12e6cec | 2014-05-13 11:38:36 +0200 | [diff] [blame] | 2308 | const char *path); |
Dave Airlie | 6f134d7 | 2014-10-20 16:30:50 +1000 | [diff] [blame] | 2309 | int drm_mode_connector_set_tile_property(struct drm_connector *connector); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2310 | extern int drm_mode_connector_update_edid_property(struct drm_connector *connector, |
Thierry Reding | 12e6cec | 2014-05-13 11:38:36 +0200 | [diff] [blame] | 2311 | const struct edid *edid); |
Rob Clark | 5ea22f2 | 2014-05-30 11:34:01 -0400 | [diff] [blame] | 2312 | |
Boris Brezillon | b5571e9 | 2014-07-22 12:09:10 +0200 | [diff] [blame] | 2313 | extern int drm_display_info_set_bus_formats(struct drm_display_info *info, |
| 2314 | const u32 *formats, |
| 2315 | unsigned int num_formats); |
| 2316 | |
Rob Clark | 5ea22f2 | 2014-05-30 11:34:01 -0400 | [diff] [blame] | 2317 | static inline bool drm_property_type_is(struct drm_property *property, |
| 2318 | uint32_t type) |
| 2319 | { |
| 2320 | /* instanceof for props.. handles extended type vs original types: */ |
| 2321 | if (property->flags & DRM_MODE_PROP_EXTENDED_TYPE) |
| 2322 | return (property->flags & DRM_MODE_PROP_EXTENDED_TYPE) == type; |
| 2323 | return property->flags & type; |
| 2324 | } |
| 2325 | |
| 2326 | static inline bool drm_property_type_valid(struct drm_property *property) |
| 2327 | { |
| 2328 | if (property->flags & DRM_MODE_PROP_EXTENDED_TYPE) |
| 2329 | return !(property->flags & DRM_MODE_PROP_LEGACY_TYPE); |
| 2330 | return !!(property->flags & DRM_MODE_PROP_LEGACY_TYPE); |
| 2331 | } |
| 2332 | |
Paulo Zanoni | c543188 | 2012-05-15 18:09:02 -0300 | [diff] [blame] | 2333 | extern int drm_object_property_set_value(struct drm_mode_object *obj, |
| 2334 | struct drm_property *property, |
| 2335 | uint64_t val); |
| 2336 | extern int drm_object_property_get_value(struct drm_mode_object *obj, |
| 2337 | struct drm_property *property, |
| 2338 | uint64_t *value); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2339 | extern int drm_framebuffer_init(struct drm_device *dev, |
| 2340 | struct drm_framebuffer *fb, |
| 2341 | const struct drm_framebuffer_funcs *funcs); |
Daniel Vetter | 786b99e | 2012-12-02 21:53:40 +0100 | [diff] [blame] | 2342 | extern struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev, |
| 2343 | uint32_t id); |
Rob Clark | f7eff60 | 2012-09-05 21:48:38 +0000 | [diff] [blame] | 2344 | extern void drm_framebuffer_unreference(struct drm_framebuffer *fb); |
| 2345 | extern void drm_framebuffer_reference(struct drm_framebuffer *fb); |
| 2346 | extern void drm_framebuffer_remove(struct drm_framebuffer *fb); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2347 | extern void drm_framebuffer_cleanup(struct drm_framebuffer *fb); |
Daniel Vetter | 3620636 | 2012-12-10 20:42:17 +0100 | [diff] [blame] | 2348 | extern void drm_framebuffer_unregister_private(struct drm_framebuffer *fb); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2349 | |
Paulo Zanoni | c543188 | 2012-05-15 18:09:02 -0300 | [diff] [blame] | 2350 | extern void drm_object_attach_property(struct drm_mode_object *obj, |
| 2351 | struct drm_property *property, |
| 2352 | uint64_t init_val); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2353 | extern struct drm_property *drm_property_create(struct drm_device *dev, int flags, |
| 2354 | const char *name, int num_values); |
Sascha Hauer | 4a67d39 | 2012-02-06 10:58:17 +0100 | [diff] [blame] | 2355 | extern struct drm_property *drm_property_create_enum(struct drm_device *dev, int flags, |
| 2356 | const char *name, |
| 2357 | const struct drm_prop_enum_list *props, |
| 2358 | int num_values); |
Rob Clark | 49e2754 | 2012-05-17 02:23:26 -0600 | [diff] [blame] | 2359 | struct drm_property *drm_property_create_bitmask(struct drm_device *dev, |
| 2360 | int flags, const char *name, |
| 2361 | const struct drm_prop_enum_list *props, |
Ville Syrjälä | 7689ffb | 2014-07-08 10:31:52 +0530 | [diff] [blame] | 2362 | int num_props, |
| 2363 | uint64_t supported_bits); |
Sascha Hauer | d9bc3c0 | 2012-02-06 10:58:18 +0100 | [diff] [blame] | 2364 | struct drm_property *drm_property_create_range(struct drm_device *dev, int flags, |
| 2365 | const char *name, |
| 2366 | uint64_t min, uint64_t max); |
Rob Clark | ebc44cf | 2012-09-12 22:22:31 -0500 | [diff] [blame] | 2367 | struct drm_property *drm_property_create_signed_range(struct drm_device *dev, |
| 2368 | int flags, const char *name, |
| 2369 | int64_t min, int64_t max); |
Rob Clark | 98f75de | 2014-05-30 11:37:03 -0400 | [diff] [blame] | 2370 | struct drm_property *drm_property_create_object(struct drm_device *dev, |
| 2371 | int flags, const char *name, uint32_t type); |
Daniel Vetter | 960cd9d | 2015-01-21 08:47:38 +0100 | [diff] [blame] | 2372 | struct drm_property *drm_property_create_bool(struct drm_device *dev, int flags, |
| 2373 | const char *name); |
Daniel Stone | 6bcacf5 | 2015-04-20 19:22:55 +0100 | [diff] [blame] | 2374 | struct drm_property_blob *drm_property_create_blob(struct drm_device *dev, |
| 2375 | size_t length, |
| 2376 | const void *data); |
| 2377 | struct drm_property_blob *drm_property_lookup_blob(struct drm_device *dev, |
| 2378 | uint32_t id); |
| 2379 | struct drm_property_blob *drm_property_reference_blob(struct drm_property_blob *blob); |
| 2380 | void drm_property_unreference_blob(struct drm_property_blob *blob); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2381 | extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property); |
| 2382 | extern int drm_property_add_enum(struct drm_property *property, int index, |
| 2383 | uint64_t value, const char *name); |
| 2384 | extern int drm_mode_create_dvi_i_properties(struct drm_device *dev); |
Thierry Reding | 2f76331 | 2014-10-13 12:45:57 +0200 | [diff] [blame] | 2385 | extern int drm_mode_create_tv_properties(struct drm_device *dev, |
| 2386 | unsigned int num_modes, |
Ville Syrjälä | b7c914b | 2015-08-31 15:09:26 +0300 | [diff] [blame] | 2387 | const char * const modes[]); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2388 | extern int drm_mode_create_scaling_mode_property(struct drm_device *dev); |
Vandana Kannan | ff587e4 | 2014-06-11 10:46:48 +0530 | [diff] [blame] | 2389 | extern int drm_mode_create_aspect_ratio_property(struct drm_device *dev); |
Jakob Bornecrantz | 884840a | 2009-12-03 23:25:47 +0000 | [diff] [blame] | 2390 | extern int drm_mode_create_dirty_info_property(struct drm_device *dev); |
Dave Airlie | 5bb2bbf | 2014-11-10 10:18:15 +1000 | [diff] [blame] | 2391 | extern int drm_mode_create_suggested_offset_properties(struct drm_device *dev); |
Rob Clark | d34f20d | 2014-12-18 16:01:56 -0500 | [diff] [blame] | 2392 | extern bool drm_property_change_valid_get(struct drm_property *property, |
| 2393 | uint64_t value, struct drm_mode_object **ref); |
| 2394 | extern void drm_property_change_valid_put(struct drm_property *property, |
| 2395 | struct drm_mode_object *ref); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2396 | |
| 2397 | extern int drm_mode_connector_attach_encoder(struct drm_connector *connector, |
| 2398 | struct drm_encoder *encoder); |
Sascha Hauer | 4cae5b8 | 2012-02-01 11:38:23 +0100 | [diff] [blame] | 2399 | extern int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2400 | int gamma_size); |
Daniel Vetter | 7a9c906 | 2009-09-15 22:57:31 +0200 | [diff] [blame] | 2401 | extern struct drm_mode_object *drm_mode_object_find(struct drm_device *dev, |
| 2402 | uint32_t id, uint32_t type); |
Rob Clark | 98f75de | 2014-05-30 11:37:03 -0400 | [diff] [blame] | 2403 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2404 | /* IOCTLs */ |
| 2405 | extern int drm_mode_getresources(struct drm_device *dev, |
| 2406 | void *data, struct drm_file *file_priv); |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 2407 | extern int drm_mode_getplane_res(struct drm_device *dev, void *data, |
| 2408 | struct drm_file *file_priv); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2409 | extern int drm_mode_getcrtc(struct drm_device *dev, |
| 2410 | void *data, struct drm_file *file_priv); |
| 2411 | extern int drm_mode_getconnector(struct drm_device *dev, |
| 2412 | void *data, struct drm_file *file_priv); |
Daniel Vetter | 2d13b67 | 2012-12-11 13:47:23 +0100 | [diff] [blame] | 2413 | extern int drm_mode_set_config_internal(struct drm_mode_set *set); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2414 | extern int drm_mode_setcrtc(struct drm_device *dev, |
| 2415 | void *data, struct drm_file *file_priv); |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 2416 | extern int drm_mode_getplane(struct drm_device *dev, |
| 2417 | void *data, struct drm_file *file_priv); |
| 2418 | extern int drm_mode_setplane(struct drm_device *dev, |
| 2419 | void *data, struct drm_file *file_priv); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2420 | extern int drm_mode_cursor_ioctl(struct drm_device *dev, |
| 2421 | void *data, struct drm_file *file_priv); |
Dave Airlie | 4c813d4 | 2013-06-20 11:48:52 +1000 | [diff] [blame] | 2422 | extern int drm_mode_cursor2_ioctl(struct drm_device *dev, |
| 2423 | void *data, struct drm_file *file_priv); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2424 | extern int drm_mode_addfb(struct drm_device *dev, |
| 2425 | void *data, struct drm_file *file_priv); |
Jesse Barnes | 308e5bc | 2011-11-14 14:51:28 -0800 | [diff] [blame] | 2426 | extern int drm_mode_addfb2(struct drm_device *dev, |
| 2427 | void *data, struct drm_file *file_priv); |
| 2428 | extern uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2429 | extern int drm_mode_rmfb(struct drm_device *dev, |
| 2430 | void *data, struct drm_file *file_priv); |
| 2431 | extern int drm_mode_getfb(struct drm_device *dev, |
| 2432 | void *data, struct drm_file *file_priv); |
Jakob Bornecrantz | 884840a | 2009-12-03 23:25:47 +0000 | [diff] [blame] | 2433 | extern int drm_mode_dirtyfb_ioctl(struct drm_device *dev, |
| 2434 | void *data, struct drm_file *file_priv); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2435 | |
| 2436 | extern int drm_mode_getproperty_ioctl(struct drm_device *dev, |
| 2437 | void *data, struct drm_file *file_priv); |
| 2438 | extern int drm_mode_getblob_ioctl(struct drm_device *dev, |
| 2439 | void *data, struct drm_file *file_priv); |
Daniel Stone | e2f5d2e | 2015-05-22 13:34:51 +0100 | [diff] [blame] | 2440 | extern int drm_mode_createblob_ioctl(struct drm_device *dev, |
| 2441 | void *data, struct drm_file *file_priv); |
| 2442 | extern int drm_mode_destroyblob_ioctl(struct drm_device *dev, |
| 2443 | void *data, struct drm_file *file_priv); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2444 | extern int drm_mode_connector_property_set_ioctl(struct drm_device *dev, |
| 2445 | void *data, struct drm_file *file_priv); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2446 | extern int drm_mode_getencoder(struct drm_device *dev, |
| 2447 | void *data, struct drm_file *file_priv); |
| 2448 | extern int drm_mode_gamma_get_ioctl(struct drm_device *dev, |
| 2449 | void *data, struct drm_file *file_priv); |
| 2450 | extern int drm_mode_gamma_set_ioctl(struct drm_device *dev, |
| 2451 | void *data, struct drm_file *file_priv); |
Thierry Reding | 18316c8 | 2012-12-20 15:41:44 +0100 | [diff] [blame] | 2452 | extern u8 drm_match_cea_mode(const struct drm_display_mode *to_match); |
Vandana Kannan | 0967e6a | 2014-04-01 16:26:59 +0530 | [diff] [blame] | 2453 | extern enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code); |
Ma Ling | f23c20c | 2009-03-26 19:26:23 +0800 | [diff] [blame] | 2454 | extern bool drm_detect_hdmi_monitor(struct edid *edid); |
Zhenyu Wang | 8fe9790 | 2010-09-19 14:27:28 +0800 | [diff] [blame] | 2455 | extern bool drm_detect_monitor_audio(struct edid *edid); |
Ville Syrjälä | b1edd6a | 2013-01-17 16:31:30 +0200 | [diff] [blame] | 2456 | extern bool drm_rgb_quant_range_selectable(struct edid *edid); |
Kristian Høgsberg | d91d8a3 | 2009-11-17 12:43:55 -0500 | [diff] [blame] | 2457 | extern int drm_mode_page_flip_ioctl(struct drm_device *dev, |
| 2458 | void *data, struct drm_file *file_priv); |
Zhao Yakui | f0fda0a | 2009-09-03 09:33:48 +0800 | [diff] [blame] | 2459 | extern int drm_add_modes_noedid(struct drm_connector *connector, |
| 2460 | int hdisplay, int vdisplay); |
Gerd Hoffmann | 3cf70da | 2013-10-11 10:01:08 +0200 | [diff] [blame] | 2461 | extern void drm_set_preferred_mode(struct drm_connector *connector, |
| 2462 | int hpref, int vpref); |
Alex Deucher | 3c53788 | 2010-02-05 04:21:19 -0500 | [diff] [blame] | 2463 | |
Thomas Reim | 051963d | 2011-07-29 14:28:57 +0000 | [diff] [blame] | 2464 | extern int drm_edid_header_is_valid(const u8 *raw_edid); |
Todd Previte | 6ba2bd3 | 2015-04-21 11:09:41 -0700 | [diff] [blame] | 2465 | extern bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid, |
| 2466 | bool *edid_corrupt); |
Alex Deucher | 3c53788 | 2010-02-05 04:21:19 -0500 | [diff] [blame] | 2467 | extern bool drm_edid_is_valid(struct edid *edid); |
Dave Airlie | 138f9eb | 2014-10-20 16:17:17 +1000 | [diff] [blame] | 2468 | |
| 2469 | extern struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev, |
| 2470 | char topology[8]); |
| 2471 | extern struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev, |
| 2472 | char topology[8]); |
| 2473 | extern void drm_mode_put_tile_group(struct drm_device *dev, |
| 2474 | struct drm_tile_group *tg); |
Dave Airlie | 1d42bbc | 2010-05-07 05:02:30 +0000 | [diff] [blame] | 2475 | struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev, |
Adam Jackson | f6e252b | 2012-04-13 16:33:31 -0400 | [diff] [blame] | 2476 | int hsize, int vsize, int fresh, |
| 2477 | bool rb); |
Dave Airlie | ff72145b | 2011-02-07 12:16:14 +1000 | [diff] [blame] | 2478 | |
| 2479 | extern int drm_mode_create_dumb_ioctl(struct drm_device *dev, |
| 2480 | void *data, struct drm_file *file_priv); |
| 2481 | extern int drm_mode_mmap_dumb_ioctl(struct drm_device *dev, |
| 2482 | void *data, struct drm_file *file_priv); |
| 2483 | extern int drm_mode_destroy_dumb_ioctl(struct drm_device *dev, |
| 2484 | void *data, struct drm_file *file_priv); |
Paulo Zanoni | c543188 | 2012-05-15 18:09:02 -0300 | [diff] [blame] | 2485 | extern int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data, |
| 2486 | struct drm_file *file_priv); |
| 2487 | extern int drm_mode_obj_set_property_ioctl(struct drm_device *dev, void *data, |
| 2488 | struct drm_file *file_priv); |
Thomas Wood | 3a5f87c | 2014-08-20 14:45:00 +0100 | [diff] [blame] | 2489 | extern int drm_mode_plane_set_obj_prop(struct drm_plane *plane, |
| 2490 | struct drm_property *property, |
| 2491 | uint64_t value); |
Rob Clark | d34f20d | 2014-12-18 16:01:56 -0500 | [diff] [blame] | 2492 | extern int drm_mode_atomic_ioctl(struct drm_device *dev, |
| 2493 | void *data, struct drm_file *file_priv); |
Dave Airlie | 248dbc2 | 2011-11-29 20:02:54 +0000 | [diff] [blame] | 2494 | |
| 2495 | extern void drm_fb_get_bpp_depth(uint32_t format, unsigned int *depth, |
| 2496 | int *bpp); |
Ville Syrjälä | 141670e | 2012-04-05 21:35:15 +0300 | [diff] [blame] | 2497 | extern int drm_format_num_planes(uint32_t format); |
Ville Syrjälä | 5a86bd5 | 2012-04-05 21:35:16 +0300 | [diff] [blame] | 2498 | extern int drm_format_plane_cpp(uint32_t format, int plane); |
Ville Syrjälä | 01b68b0 | 2012-04-05 21:35:17 +0300 | [diff] [blame] | 2499 | extern int drm_format_horz_chroma_subsampling(uint32_t format); |
| 2500 | extern int drm_format_vert_chroma_subsampling(uint32_t format); |
Ville Syrjälä | 4c61716 | 2016-02-09 17:29:44 +0200 | [diff] [blame] | 2501 | extern int drm_format_plane_width(int width, uint32_t format, int plane); |
| 2502 | extern int drm_format_plane_height(int height, uint32_t format, int plane); |
Ville Syrjälä | d20d317 | 2013-06-07 15:43:07 +0000 | [diff] [blame] | 2503 | extern const char *drm_get_format_name(uint32_t format); |
Ville Syrjälä | c1df5f3 | 2014-07-08 10:31:53 +0530 | [diff] [blame] | 2504 | extern struct drm_property *drm_mode_create_rotation_property(struct drm_device *dev, |
| 2505 | unsigned int supported_rotations); |
Ville Syrjälä | 3c9855f | 2014-07-08 10:31:56 +0530 | [diff] [blame] | 2506 | extern unsigned int drm_rotation_simplify(unsigned int rotation, |
| 2507 | unsigned int supported_rotations); |
Ville Syrjälä | 141670e | 2012-04-05 21:35:15 +0300 | [diff] [blame] | 2508 | |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 2509 | /* Helpers */ |
Rob Clark | a2b34e2 | 2013-10-05 16:36:52 -0400 | [diff] [blame] | 2510 | |
| 2511 | static inline struct drm_plane *drm_plane_find(struct drm_device *dev, |
| 2512 | uint32_t id) |
| 2513 | { |
| 2514 | struct drm_mode_object *mo; |
| 2515 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_PLANE); |
| 2516 | return mo ? obj_to_plane(mo) : NULL; |
| 2517 | } |
| 2518 | |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 2519 | static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev, |
| 2520 | uint32_t id) |
| 2521 | { |
| 2522 | struct drm_mode_object *mo; |
| 2523 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CRTC); |
| 2524 | return mo ? obj_to_crtc(mo) : NULL; |
| 2525 | } |
| 2526 | |
| 2527 | static inline struct drm_encoder *drm_encoder_find(struct drm_device *dev, |
| 2528 | uint32_t id) |
| 2529 | { |
| 2530 | struct drm_mode_object *mo; |
| 2531 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_ENCODER); |
| 2532 | return mo ? obj_to_encoder(mo) : NULL; |
| 2533 | } |
| 2534 | |
Rob Clark | a2b34e2 | 2013-10-05 16:36:52 -0400 | [diff] [blame] | 2535 | static inline struct drm_connector *drm_connector_find(struct drm_device *dev, |
| 2536 | uint32_t id) |
| 2537 | { |
| 2538 | struct drm_mode_object *mo; |
| 2539 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CONNECTOR); |
| 2540 | return mo ? obj_to_connector(mo) : NULL; |
| 2541 | } |
| 2542 | |
| 2543 | static inline struct drm_property *drm_property_find(struct drm_device *dev, |
| 2544 | uint32_t id) |
| 2545 | { |
| 2546 | struct drm_mode_object *mo; |
| 2547 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_PROPERTY); |
| 2548 | return mo ? obj_to_property(mo) : NULL; |
| 2549 | } |
| 2550 | |
Matt Roper | e27dde3 | 2014-04-01 15:22:30 -0700 | [diff] [blame] | 2551 | /* Plane list iterator for legacy (overlay only) planes. */ |
Daniel Vetter | 4ea50e9 | 2015-07-09 23:44:24 +0200 | [diff] [blame] | 2552 | #define drm_for_each_legacy_plane(plane, dev) \ |
| 2553 | list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) \ |
Jani Nikula | 373701b | 2015-11-24 21:21:55 +0200 | [diff] [blame] | 2554 | for_each_if (plane->type == DRM_PLANE_TYPE_OVERLAY) |
Matt Roper | e27dde3 | 2014-04-01 15:22:30 -0700 | [diff] [blame] | 2555 | |
Daniel Vetter | 6295d60 | 2015-07-09 23:44:25 +0200 | [diff] [blame] | 2556 | #define drm_for_each_plane(plane, dev) \ |
| 2557 | list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) |
| 2558 | |
| 2559 | #define drm_for_each_crtc(crtc, dev) \ |
| 2560 | list_for_each_entry(crtc, &(dev)->mode_config.crtc_list, head) |
| 2561 | |
Daniel Vetter | 7a3f3d6 | 2015-07-09 23:44:28 +0200 | [diff] [blame] | 2562 | static inline void |
| 2563 | assert_drm_connector_list_read_locked(struct drm_mode_config *mode_config) |
| 2564 | { |
Daniel Vetter | cff20ba | 2015-07-09 23:44:33 +0200 | [diff] [blame] | 2565 | /* |
| 2566 | * The connector hotadd/remove code currently grabs both locks when |
| 2567 | * updating lists. Hence readers need only hold either of them to be |
| 2568 | * safe and the check amounts to |
| 2569 | * |
| 2570 | * WARN_ON(not_holding(A) && not_holding(B)). |
| 2571 | */ |
| 2572 | WARN_ON(!mutex_is_locked(&mode_config->mutex) && |
| 2573 | !drm_modeset_is_locked(&mode_config->connection_mutex)); |
Daniel Vetter | 7a3f3d6 | 2015-07-09 23:44:28 +0200 | [diff] [blame] | 2574 | } |
| 2575 | |
Daniel Vetter | 6295d60 | 2015-07-09 23:44:25 +0200 | [diff] [blame] | 2576 | #define drm_for_each_connector(connector, dev) \ |
Daniel Vetter | 7a3f3d6 | 2015-07-09 23:44:28 +0200 | [diff] [blame] | 2577 | for (assert_drm_connector_list_read_locked(&(dev)->mode_config), \ |
| 2578 | connector = list_first_entry(&(dev)->mode_config.connector_list, \ |
| 2579 | struct drm_connector, head); \ |
| 2580 | &connector->head != (&(dev)->mode_config.connector_list); \ |
| 2581 | connector = list_next_entry(connector, head)) |
Daniel Vetter | 6295d60 | 2015-07-09 23:44:25 +0200 | [diff] [blame] | 2582 | |
| 2583 | #define drm_for_each_encoder(encoder, dev) \ |
| 2584 | list_for_each_entry(encoder, &(dev)->mode_config.encoder_list, head) |
| 2585 | |
| 2586 | #define drm_for_each_fb(fb, dev) \ |
Daniel Vetter | 4676ba0 | 2015-07-09 23:44:30 +0200 | [diff] [blame] | 2587 | for (WARN_ON(!mutex_is_locked(&(dev)->mode_config.fb_lock)), \ |
| 2588 | fb = list_first_entry(&(dev)->mode_config.fb_list, \ |
| 2589 | struct drm_framebuffer, head); \ |
| 2590 | &fb->head != (&(dev)->mode_config.fb_list); \ |
| 2591 | fb = list_next_entry(fb, head)) |
Daniel Vetter | 6295d60 | 2015-07-09 23:44:25 +0200 | [diff] [blame] | 2592 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2593 | #endif /* __DRM_CRTC_H__ */ |