Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2006 Keith Packard |
| 3 | * Copyright © 2007-2008 Dave Airlie |
| 4 | * Copyright © 2007-2008 Intel Corporation |
| 5 | * Jesse Barnes <jesse.barnes@intel.com> |
| 6 | * |
| 7 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 8 | * copy of this software and associated documentation files (the "Software"), |
| 9 | * to deal in the Software without restriction, including without limitation |
| 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 11 | * and/or sell copies of the Software, and to permit persons to whom the |
| 12 | * Software is furnished to do so, subject to the following conditions: |
| 13 | * |
| 14 | * The above copyright notice and this permission notice shall be included in |
| 15 | * all copies or substantial portions of the Software. |
| 16 | * |
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 20 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 21 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 22 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 23 | * OTHER DEALINGS IN THE SOFTWARE. |
| 24 | */ |
| 25 | #ifndef __DRM_CRTC_H__ |
| 26 | #define __DRM_CRTC_H__ |
| 27 | |
| 28 | #include <linux/i2c.h> |
| 29 | #include <linux/spinlock.h> |
| 30 | #include <linux/types.h> |
| 31 | #include <linux/idr.h> |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 32 | #include <linux/fb.h> |
Vandana Kannan | 985e5dc | 2013-12-19 15:34:07 +0530 | [diff] [blame] | 33 | #include <linux/hdmi.h> |
Boris Brezillon | b5571e9 | 2014-07-22 12:09:10 +0200 | [diff] [blame] | 34 | #include <linux/media-bus-format.h> |
David Herrmann | d7d2c48 | 2014-08-29 12:12:40 +0200 | [diff] [blame] | 35 | #include <uapi/drm/drm_mode.h> |
| 36 | #include <uapi/drm/drm_fourcc.h> |
Rob Clark | 51fd371 | 2013-11-19 12:10:12 -0500 | [diff] [blame] | 37 | #include <drm/drm_modeset_lock.h> |
Ville Syrjälä | d7da824 | 2016-07-26 19:06:57 +0300 | [diff] [blame^] | 38 | #include <drm/drm_rect.h> |
Jesse Barnes | 308e5bc | 2011-11-14 14:51:28 -0800 | [diff] [blame] | 39 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 40 | struct drm_device; |
| 41 | struct drm_mode_set; |
| 42 | struct drm_framebuffer; |
Paulo Zanoni | 7e3bdf4 | 2012-05-15 18:09:01 -0300 | [diff] [blame] | 43 | struct drm_object_properties; |
Thierry Reding | 595887e | 2012-11-21 15:00:47 +0100 | [diff] [blame] | 44 | struct drm_file; |
| 45 | struct drm_clip_rect; |
Russell King | 7e435aa | 2014-06-15 11:07:12 +0100 | [diff] [blame] | 46 | struct device_node; |
Daniel Vetter | e2330f0 | 2014-10-29 11:34:56 +0100 | [diff] [blame] | 47 | struct fence; |
Daniel Vetter | 8106554 | 2016-06-21 10:54:13 +0200 | [diff] [blame] | 48 | struct edid; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 49 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 50 | struct drm_mode_object { |
| 51 | uint32_t id; |
| 52 | uint32_t type; |
Paulo Zanoni | 7e3bdf4 | 2012-05-15 18:09:01 -0300 | [diff] [blame] | 53 | struct drm_object_properties *properties; |
Dave Airlie | d0f37cf6 | 2016-04-15 15:10:36 +1000 | [diff] [blame] | 54 | struct kref refcount; |
| 55 | void (*free_cb)(struct kref *kref); |
Paulo Zanoni | 7e3bdf4 | 2012-05-15 18:09:01 -0300 | [diff] [blame] | 56 | }; |
| 57 | |
Paulo Zanoni | fe45616 | 2012-06-12 11:27:01 -0300 | [diff] [blame] | 58 | #define DRM_OBJECT_MAX_PROPERTY 24 |
Paulo Zanoni | 7e3bdf4 | 2012-05-15 18:09:01 -0300 | [diff] [blame] | 59 | struct drm_object_properties { |
Rob Clark | 88a48e2 | 2014-12-18 16:01:50 -0500 | [diff] [blame] | 60 | int count, atomic_count; |
Rob Clark | b17cd75 | 2014-12-16 18:05:30 -0500 | [diff] [blame] | 61 | /* NOTE: if we ever start dynamically destroying properties (ie. |
| 62 | * not at drm_mode_config_cleanup() time), then we'd have to do |
| 63 | * a better job of detaching property from mode objects to avoid |
| 64 | * dangling property pointers: |
| 65 | */ |
| 66 | struct drm_property *properties[DRM_OBJECT_MAX_PROPERTY]; |
Rob Clark | 22b8b13 | 2014-12-16 18:05:31 -0500 | [diff] [blame] | 67 | /* do not read/write values directly, but use drm_object_property_get_value() |
| 68 | * and drm_object_property_set_value(): |
| 69 | */ |
Paulo Zanoni | 7e3bdf4 | 2012-05-15 18:09:01 -0300 | [diff] [blame] | 70 | uint64_t values[DRM_OBJECT_MAX_PROPERTY]; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 71 | }; |
| 72 | |
Rob Clark | ebc44cf | 2012-09-12 22:22:31 -0500 | [diff] [blame] | 73 | static inline int64_t U642I64(uint64_t val) |
| 74 | { |
| 75 | return (int64_t)*((int64_t *)&val); |
| 76 | } |
| 77 | static inline uint64_t I642U64(int64_t val) |
| 78 | { |
| 79 | return (uint64_t)*((uint64_t *)&val); |
| 80 | } |
| 81 | |
Robert Fekete | d9c3824 | 2015-11-02 16:14:08 +0100 | [diff] [blame] | 82 | /* |
| 83 | * Rotation property bits. DRM_ROTATE_<degrees> rotates the image by the |
| 84 | * specified amount in degrees in counter clockwise direction. DRM_REFLECT_X and |
| 85 | * DRM_REFLECT_Y reflects the image along the specified axis prior to rotation |
| 86 | */ |
Joonas Lahtinen | 31ad61e | 2016-07-29 08:50:05 +0300 | [diff] [blame] | 87 | #define DRM_ROTATE_0 BIT(0) |
| 88 | #define DRM_ROTATE_90 BIT(1) |
| 89 | #define DRM_ROTATE_180 BIT(2) |
| 90 | #define DRM_ROTATE_270 BIT(3) |
| 91 | #define DRM_ROTATE_MASK (DRM_ROTATE_0 | DRM_ROTATE_90 | \ |
| 92 | DRM_ROTATE_180 | DRM_ROTATE_270) |
| 93 | #define DRM_REFLECT_X BIT(4) |
| 94 | #define DRM_REFLECT_Y BIT(5) |
| 95 | #define DRM_REFLECT_MASK (DRM_REFLECT_X | DRM_REFLECT_Y) |
Ville Syrjälä | 0659696 | 2014-07-08 10:31:51 +0530 | [diff] [blame] | 96 | |
Daniel Vetter | 5531000 | 2014-01-23 15:52:20 +0100 | [diff] [blame] | 97 | enum drm_connector_force { |
| 98 | DRM_FORCE_UNSPECIFIED, |
| 99 | DRM_FORCE_OFF, |
| 100 | DRM_FORCE_ON, /* force on analog part normally */ |
| 101 | DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 102 | }; |
| 103 | |
Daniel Vetter | 5531000 | 2014-01-23 15:52:20 +0100 | [diff] [blame] | 104 | #include <drm/drm_modes.h> |
Damien Lespiau | 4aa17cf | 2013-09-25 16:45:21 +0100 | [diff] [blame] | 105 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 106 | enum drm_connector_status { |
| 107 | connector_status_connected = 1, |
| 108 | connector_status_disconnected = 2, |
| 109 | connector_status_unknown = 3, |
| 110 | }; |
| 111 | |
| 112 | enum subpixel_order { |
| 113 | SubPixelUnknown = 0, |
| 114 | SubPixelHorizontalRGB, |
| 115 | SubPixelHorizontalBGR, |
| 116 | SubPixelVerticalRGB, |
| 117 | SubPixelVerticalBGR, |
| 118 | SubPixelNone, |
| 119 | }; |
| 120 | |
Jesse Barnes | da05a5a7 | 2011-04-15 13:48:57 -0700 | [diff] [blame] | 121 | #define DRM_COLOR_FORMAT_RGB444 (1<<0) |
| 122 | #define DRM_COLOR_FORMAT_YCRCB444 (1<<1) |
| 123 | #define DRM_COLOR_FORMAT_YCRCB422 (1<<2) |
Stefan Agner | f0aa083 | 2016-02-08 11:38:14 -0800 | [diff] [blame] | 124 | |
| 125 | #define DRM_BUS_FLAG_DE_LOW (1<<0) |
| 126 | #define DRM_BUS_FLAG_DE_HIGH (1<<1) |
| 127 | /* drive data on pos. edge */ |
| 128 | #define DRM_BUS_FLAG_PIXDATA_POSEDGE (1<<2) |
| 129 | /* drive data on neg. edge */ |
| 130 | #define DRM_BUS_FLAG_PIXDATA_NEGEDGE (1<<3) |
| 131 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 132 | /* |
| 133 | * Describes a given display (e.g. CRT or flat panel) and its limitations. |
| 134 | */ |
| 135 | struct drm_display_info { |
| 136 | char name[DRM_DISPLAY_INFO_LEN]; |
Adam Jackson | fb43964 | 2010-08-03 14:38:16 -0400 | [diff] [blame] | 137 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 138 | /* Physical size */ |
| 139 | unsigned int width_mm; |
| 140 | unsigned int height_mm; |
| 141 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 142 | /* Clock limits FIXME: storage format */ |
| 143 | unsigned int min_vfreq, max_vfreq; |
| 144 | unsigned int min_hfreq, max_hfreq; |
| 145 | unsigned int pixel_clock; |
Jesse Barnes | 3b11228 | 2011-04-15 12:49:23 -0700 | [diff] [blame] | 146 | unsigned int bpc; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 147 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 148 | enum subpixel_order subpixel_order; |
Jesse Barnes | da05a5a7 | 2011-04-15 13:48:57 -0700 | [diff] [blame] | 149 | u32 color_formats; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 150 | |
Boris Brezillon | b5571e9 | 2014-07-22 12:09:10 +0200 | [diff] [blame] | 151 | const u32 *bus_formats; |
| 152 | unsigned int num_bus_formats; |
Stefan Agner | f0aa083 | 2016-02-08 11:38:14 -0800 | [diff] [blame] | 153 | u32 bus_flags; |
Boris Brezillon | b5571e9 | 2014-07-22 12:09:10 +0200 | [diff] [blame] | 154 | |
Mario Kleiner | 5d02626d | 2014-06-05 09:52:10 -0400 | [diff] [blame] | 155 | /* Mask of supported hdmi deep color modes */ |
| 156 | u8 edid_hdmi_dc_modes; |
| 157 | |
Jesse Barnes | ebec9a7 | 2011-08-03 09:22:54 -0700 | [diff] [blame] | 158 | u8 cea_rev; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 159 | }; |
| 160 | |
Dave Airlie | 138f9eb | 2014-10-20 16:17:17 +1000 | [diff] [blame] | 161 | /* data corresponds to displayid vend/prod/serial */ |
| 162 | struct drm_tile_group { |
| 163 | struct kref refcount; |
| 164 | struct drm_device *dev; |
| 165 | int id; |
| 166 | u8 group_data[8]; |
| 167 | }; |
| 168 | |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 169 | /** |
| 170 | * struct drm_framebuffer_funcs - framebuffer hooks |
| 171 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 172 | struct drm_framebuffer_funcs { |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 173 | /** |
| 174 | * @destroy: |
| 175 | * |
| 176 | * Clean up framebuffer resources, specifically also unreference the |
| 177 | * backing storage. The core guarantees to call this function for every |
| 178 | * framebuffer successfully created by ->fb_create() in |
Daniel Vetter | d55f532 | 2015-12-08 09:49:19 +0100 | [diff] [blame] | 179 | * &drm_mode_config_funcs. Drivers must also call |
| 180 | * drm_framebuffer_cleanup() to release DRM core resources for this |
| 181 | * framebuffer. |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 182 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 183 | void (*destroy)(struct drm_framebuffer *framebuffer); |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 184 | |
| 185 | /** |
| 186 | * @create_handle: |
| 187 | * |
| 188 | * Create a buffer handle in the driver-specific buffer manager (either |
| 189 | * GEM or TTM) valid for the passed-in struct &drm_file. This is used by |
| 190 | * the core to implement the GETFB IOCTL, which returns (for |
| 191 | * sufficiently priviledged user) also a native buffer handle. This can |
| 192 | * be used for seamless transitions between modesetting clients by |
| 193 | * copying the current screen contents to a private buffer and blending |
| 194 | * between that and the new contents. |
| 195 | * |
Daniel Vetter | d55f532 | 2015-12-08 09:49:19 +0100 | [diff] [blame] | 196 | * GEM based drivers should call drm_gem_handle_create() to create the |
| 197 | * handle. |
| 198 | * |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 199 | * RETURNS: |
| 200 | * |
| 201 | * 0 on success or a negative error code on failure. |
| 202 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 203 | int (*create_handle)(struct drm_framebuffer *fb, |
| 204 | struct drm_file *file_priv, |
| 205 | unsigned int *handle); |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 206 | /** |
| 207 | * @dirty: |
Jakob Bornecrantz | 884840a | 2009-12-03 23:25:47 +0000 | [diff] [blame] | 208 | * |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 209 | * Optional callback for the dirty fb IOCTL. |
Jakob Bornecrantz | 884840a | 2009-12-03 23:25:47 +0000 | [diff] [blame] | 210 | * |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 211 | * Userspace can notify the driver via this callback that an area of the |
| 212 | * framebuffer has changed and should be flushed to the display |
| 213 | * hardware. This can also be used internally, e.g. by the fbdev |
| 214 | * emulation, though that's not the case currently. |
| 215 | * |
| 216 | * See documentation in drm_mode.h for the struct drm_mode_fb_dirty_cmd |
| 217 | * for more information as all the semantics and arguments have a one to |
| 218 | * one mapping on this function. |
| 219 | * |
| 220 | * RETURNS: |
| 221 | * |
| 222 | * 0 on success or a negative error code on failure. |
Jakob Bornecrantz | 884840a | 2009-12-03 23:25:47 +0000 | [diff] [blame] | 223 | */ |
Thomas Hellstrom | 02b0016 | 2010-10-05 12:43:02 +0200 | [diff] [blame] | 224 | int (*dirty)(struct drm_framebuffer *framebuffer, |
| 225 | struct drm_file *file_priv, unsigned flags, |
Jakob Bornecrantz | 884840a | 2009-12-03 23:25:47 +0000 | [diff] [blame] | 226 | unsigned color, struct drm_clip_rect *clips, |
| 227 | unsigned num_clips); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 228 | }; |
| 229 | |
| 230 | struct drm_framebuffer { |
| 231 | struct drm_device *dev; |
Rob Clark | f7eff60 | 2012-09-05 21:48:38 +0000 | [diff] [blame] | 232 | /* |
| 233 | * Note that the fb is refcounted for the benefit of driver internals, |
| 234 | * for example some hw, disabling a CRTC/plane is asynchronous, and |
| 235 | * scanout does not actually complete until the next vblank. So some |
| 236 | * cleanup (like releasing the reference(s) on the backing GEM bo(s)) |
| 237 | * should be deferred. In cases like this, the driver would like to |
| 238 | * hold a ref to the fb even though it has already been removed from |
| 239 | * userspace perspective. |
Dave Airlie | d0f37cf6 | 2016-04-15 15:10:36 +1000 | [diff] [blame] | 240 | * The refcount is stored inside the mode object. |
Rob Clark | f7eff60 | 2012-09-05 21:48:38 +0000 | [diff] [blame] | 241 | */ |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 242 | /* |
| 243 | * Place on the dev->mode_config.fb_list, access protected by |
| 244 | * dev->mode_config.fb_lock. |
| 245 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 246 | struct list_head head; |
| 247 | struct drm_mode_object base; |
| 248 | const struct drm_framebuffer_funcs *funcs; |
Ville Syrjälä | 01f2c77 | 2011-12-20 00:06:49 +0200 | [diff] [blame] | 249 | unsigned int pitches[4]; |
| 250 | unsigned int offsets[4]; |
Rob Clark | e3eb325 | 2015-02-05 14:41:52 +0000 | [diff] [blame] | 251 | uint64_t modifier[4]; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 252 | unsigned int width; |
| 253 | unsigned int height; |
| 254 | /* depth can be 15 or 16 */ |
| 255 | unsigned int depth; |
| 256 | int bits_per_pixel; |
| 257 | int flags; |
Jesse Barnes | 308e5bc | 2011-11-14 14:51:28 -0800 | [diff] [blame] | 258 | uint32_t pixel_format; /* fourcc format */ |
Gerd Hoffmann | dd54659 | 2016-05-31 08:54:52 +0200 | [diff] [blame] | 259 | int hot_x; |
| 260 | int hot_y; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 261 | struct list_head filp_head; |
| 262 | }; |
| 263 | |
| 264 | struct drm_property_blob { |
| 265 | struct drm_mode_object base; |
Daniel Stone | 6bcacf5 | 2015-04-20 19:22:55 +0100 | [diff] [blame] | 266 | struct drm_device *dev; |
Daniel Stone | e2f5d2e | 2015-05-22 13:34:51 +0100 | [diff] [blame] | 267 | struct list_head head_global; |
| 268 | struct list_head head_file; |
Thierry Reding | ecbbe59 | 2014-05-13 11:36:13 +0200 | [diff] [blame] | 269 | size_t length; |
Ville Syrjälä | d63f5e6 | 2012-03-13 12:35:49 +0200 | [diff] [blame] | 270 | unsigned char data[]; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 271 | }; |
| 272 | |
| 273 | struct drm_property_enum { |
| 274 | uint64_t value; |
| 275 | struct list_head head; |
| 276 | char name[DRM_PROP_NAME_LEN]; |
| 277 | }; |
| 278 | |
| 279 | struct drm_property { |
| 280 | struct list_head head; |
| 281 | struct drm_mode_object base; |
| 282 | uint32_t flags; |
| 283 | char name[DRM_PROP_NAME_LEN]; |
| 284 | uint32_t num_values; |
| 285 | uint64_t *values; |
Rob Clark | 98f75de | 2014-05-30 11:37:03 -0400 | [diff] [blame] | 286 | struct drm_device *dev; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 287 | |
Daniel Vetter | 3758b34 | 2014-11-19 18:38:10 +0100 | [diff] [blame] | 288 | struct list_head enum_list; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 289 | }; |
| 290 | |
| 291 | struct drm_crtc; |
| 292 | struct drm_connector; |
| 293 | struct drm_encoder; |
Kristian Høgsberg | d91d8a3 | 2009-11-17 12:43:55 -0500 | [diff] [blame] | 294 | struct drm_pending_vblank_event; |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 295 | struct drm_plane; |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 296 | struct drm_bridge; |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 297 | struct drm_atomic_state; |
| 298 | |
Daniel Vetter | 4490d4c | 2015-12-04 09:45:45 +0100 | [diff] [blame] | 299 | struct drm_crtc_helper_funcs; |
| 300 | struct drm_encoder_helper_funcs; |
| 301 | struct drm_connector_helper_funcs; |
| 302 | struct drm_plane_helper_funcs; |
| 303 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 304 | /** |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 305 | * struct drm_crtc_state - mutable CRTC state |
Daniel Vetter | 07cc0ef | 2014-11-27 15:49:39 +0100 | [diff] [blame] | 306 | * @crtc: backpointer to the CRTC |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 307 | * @enable: whether the CRTC should be enabled, gates all other state |
Daniel Vetter | d9b1362 | 2014-11-26 16:57:41 +0100 | [diff] [blame] | 308 | * @active: whether the CRTC is actively displaying (used for DPMS) |
Maarten Lankhorst | fc59666 | 2015-07-21 13:28:57 +0200 | [diff] [blame] | 309 | * @planes_changed: planes on this crtc are updated |
| 310 | * @mode_changed: crtc_state->mode or crtc_state->enable has been changed |
| 311 | * @active_changed: crtc_state->active has been toggled. |
| 312 | * @connectors_changed: connectors to this crtc have been updated |
Marek Szyprowski | 44d1240d | 2016-06-13 11:11:26 +0200 | [diff] [blame] | 313 | * @zpos_changed: zpos values of planes on this crtc have been updated |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 314 | * @color_mgmt_changed: color management properties have changed (degamma or |
| 315 | * gamma LUT or CSC matrix) |
Rob Clark | 6ddd388 | 2014-11-21 15:28:31 -0500 | [diff] [blame] | 316 | * @plane_mask: bitmask of (1 << drm_plane_index(plane)) of attached planes |
Maarten Lankhorst | 4cd9fa5 | 2016-01-04 12:53:18 +0100 | [diff] [blame] | 317 | * @connector_mask: bitmask of (1 << drm_connector_index(connector)) of attached connectors |
Maarten Lankhorst | e87a52b | 2016-01-28 15:04:58 +0100 | [diff] [blame] | 318 | * @encoder_mask: bitmask of (1 << drm_encoder_index(encoder)) of attached encoders |
Daniel Vetter | 623369e | 2014-09-16 17:50:47 +0200 | [diff] [blame] | 319 | * @last_vblank_count: for helpers and drivers to capture the vblank of the |
| 320 | * update to ensure framebuffer cleanup isn't done too early |
Daniel Vetter | 2f324b4 | 2014-10-29 11:13:47 +0100 | [diff] [blame] | 321 | * @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] | 322 | * @mode: current mode timings |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 323 | * @mode_blob: &drm_property_blob for @mode |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 324 | * @degamma_lut: Lookup table for converting framebuffer pixel data |
| 325 | * before apply the conversion matrix |
| 326 | * @ctm: Transformation matrix |
| 327 | * @gamma_lut: Lookup table for converting pixel data after the |
| 328 | * conversion matrix |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 329 | * @event: optional pointer to a DRM event to signal upon completion of the |
| 330 | * state update |
| 331 | * @state: backpointer to global drm_atomic_state |
Daniel Vetter | d9b1362 | 2014-11-26 16:57:41 +0100 | [diff] [blame] | 332 | * |
| 333 | * Note that the distinction between @enable and @active is rather subtile: |
| 334 | * Flipping @active while @enable is set without changing anything else may |
| 335 | * never return in a failure from the ->atomic_check callback. Userspace assumes |
| 336 | * that a DPMS On will always succeed. In other words: @enable controls resource |
| 337 | * assignment, @active controls the actual hardware state. |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 338 | */ |
| 339 | struct drm_crtc_state { |
Daniel Vetter | 07cc0ef | 2014-11-27 15:49:39 +0100 | [diff] [blame] | 340 | struct drm_crtc *crtc; |
| 341 | |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 342 | bool enable; |
Daniel Vetter | d9b1362 | 2014-11-26 16:57:41 +0100 | [diff] [blame] | 343 | bool active; |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 344 | |
Daniel Vetter | c2fcd27 | 2014-11-05 00:14:14 +0100 | [diff] [blame] | 345 | /* computed state bits used by helpers and drivers */ |
| 346 | bool planes_changed : 1; |
Daniel Vetter | 623369e | 2014-09-16 17:50:47 +0200 | [diff] [blame] | 347 | bool mode_changed : 1; |
Daniel Vetter | eab3bbe | 2015-01-22 16:36:21 +0100 | [diff] [blame] | 348 | bool active_changed : 1; |
Maarten Lankhorst | fc59666 | 2015-07-21 13:28:57 +0200 | [diff] [blame] | 349 | bool connectors_changed : 1; |
Marek Szyprowski | 44d1240d | 2016-06-13 11:11:26 +0200 | [diff] [blame] | 350 | bool zpos_changed : 1; |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 351 | bool color_mgmt_changed : 1; |
Daniel Vetter | 623369e | 2014-09-16 17:50:47 +0200 | [diff] [blame] | 352 | |
Rob Clark | 6ddd388 | 2014-11-21 15:28:31 -0500 | [diff] [blame] | 353 | /* attached planes bitmask: |
| 354 | * WARNING: transitional helpers do not maintain plane_mask so |
| 355 | * drivers not converted over to atomic helpers should not rely |
| 356 | * on plane_mask being accurate! |
| 357 | */ |
| 358 | u32 plane_mask; |
| 359 | |
Maarten Lankhorst | 4cd9fa5 | 2016-01-04 12:53:18 +0100 | [diff] [blame] | 360 | u32 connector_mask; |
Maarten Lankhorst | e87a52b | 2016-01-28 15:04:58 +0100 | [diff] [blame] | 361 | u32 encoder_mask; |
Maarten Lankhorst | 4cd9fa5 | 2016-01-04 12:53:18 +0100 | [diff] [blame] | 362 | |
Daniel Vetter | 623369e | 2014-09-16 17:50:47 +0200 | [diff] [blame] | 363 | /* last_vblank_count: for vblank waits before cleanup */ |
| 364 | u32 last_vblank_count; |
Daniel Vetter | c2fcd27 | 2014-11-05 00:14:14 +0100 | [diff] [blame] | 365 | |
Daniel Vetter | 2f324b4 | 2014-10-29 11:13:47 +0100 | [diff] [blame] | 366 | /* adjusted_mode: for use by helpers and drivers */ |
| 367 | struct drm_display_mode adjusted_mode; |
| 368 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 369 | struct drm_display_mode mode; |
| 370 | |
Daniel Stone | 99cf4a2 | 2015-05-25 19:11:51 +0100 | [diff] [blame] | 371 | /* blob property to expose current mode to atomic userspace */ |
| 372 | struct drm_property_blob *mode_blob; |
| 373 | |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 374 | /* blob property to expose color management to userspace */ |
| 375 | struct drm_property_blob *degamma_lut; |
| 376 | struct drm_property_blob *ctm; |
| 377 | struct drm_property_blob *gamma_lut; |
| 378 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 379 | struct drm_pending_vblank_event *event; |
| 380 | |
| 381 | struct drm_atomic_state *state; |
| 382 | }; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 383 | |
| 384 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 385 | * struct drm_crtc_funcs - control CRTCs for a given device |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 386 | * |
| 387 | * The drm_crtc_funcs structure is the central CRTC management structure |
| 388 | * in the DRM. Each CRTC controls one or more connectors (note that the name |
| 389 | * CRTC is simply historical, a CRTC may control LVDS, VGA, DVI, TV out, etc. |
| 390 | * connectors, not just CRTs). |
| 391 | * |
| 392 | * Each driver is responsible for filling out this structure at startup time, |
| 393 | * in addition to providing other modesetting features, like i2c and DDC |
| 394 | * bus accessors. |
| 395 | */ |
| 396 | struct drm_crtc_funcs { |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 397 | /** |
| 398 | * @reset: |
| 399 | * |
| 400 | * Reset CRTC hardware and software state to off. This function isn't |
| 401 | * called by the core directly, only through drm_mode_config_reset(). |
| 402 | * It's not a helper hook only for historical reasons. |
| 403 | * |
| 404 | * Atomic drivers can use drm_atomic_helper_crtc_reset() to reset |
| 405 | * atomic state using this hook. |
| 406 | */ |
Chris Wilson | eb03355 | 2011-01-24 15:11:08 +0000 | [diff] [blame] | 407 | void (*reset)(struct drm_crtc *crtc); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 408 | |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 409 | /** |
| 410 | * @cursor_set: |
| 411 | * |
| 412 | * Update the cursor image. The cursor position is relative to the CRTC |
| 413 | * and can be partially or fully outside of the visible area. |
| 414 | * |
| 415 | * Note that contrary to all other KMS functions the legacy cursor entry |
| 416 | * points don't take a framebuffer object, but instead take directly a |
| 417 | * raw buffer object id from the driver's buffer manager (which is |
| 418 | * either GEM or TTM for current drivers). |
| 419 | * |
| 420 | * This entry point is deprecated, drivers should instead implement |
| 421 | * universal plane support and register a proper cursor plane using |
| 422 | * drm_crtc_init_with_planes(). |
| 423 | * |
| 424 | * This callback is optional |
| 425 | * |
| 426 | * RETURNS: |
| 427 | * |
| 428 | * 0 on success or a negative error code on failure. |
| 429 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 430 | int (*cursor_set)(struct drm_crtc *crtc, struct drm_file *file_priv, |
| 431 | uint32_t handle, uint32_t width, uint32_t height); |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 432 | |
| 433 | /** |
| 434 | * @cursor_set2: |
| 435 | * |
| 436 | * Update the cursor image, including hotspot information. The hotspot |
| 437 | * must not affect the cursor position in CRTC coordinates, but is only |
| 438 | * meant as a hint for virtualized display hardware to coordinate the |
| 439 | * guests and hosts cursor position. The cursor hotspot is relative to |
| 440 | * the cursor image. Otherwise this works exactly like @cursor_set. |
| 441 | * |
| 442 | * This entry point is deprecated, drivers should instead implement |
| 443 | * universal plane support and register a proper cursor plane using |
| 444 | * drm_crtc_init_with_planes(). |
| 445 | * |
| 446 | * This callback is optional. |
| 447 | * |
| 448 | * RETURNS: |
| 449 | * |
| 450 | * 0 on success or a negative error code on failure. |
| 451 | */ |
Dave Airlie | 4c813d4 | 2013-06-20 11:48:52 +1000 | [diff] [blame] | 452 | int (*cursor_set2)(struct drm_crtc *crtc, struct drm_file *file_priv, |
| 453 | uint32_t handle, uint32_t width, uint32_t height, |
| 454 | int32_t hot_x, int32_t hot_y); |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 455 | |
| 456 | /** |
| 457 | * @cursor_move: |
| 458 | * |
| 459 | * Update the cursor position. The cursor does not need to be visible |
| 460 | * when this hook is called. |
| 461 | * |
| 462 | * This entry point is deprecated, drivers should instead implement |
| 463 | * universal plane support and register a proper cursor plane using |
| 464 | * drm_crtc_init_with_planes(). |
| 465 | * |
| 466 | * This callback is optional. |
| 467 | * |
| 468 | * RETURNS: |
| 469 | * |
| 470 | * 0 on success or a negative error code on failure. |
| 471 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 472 | int (*cursor_move)(struct drm_crtc *crtc, int x, int y); |
| 473 | |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 474 | /** |
| 475 | * @gamma_set: |
| 476 | * |
| 477 | * Set gamma on the CRTC. |
| 478 | * |
| 479 | * This callback is optional. |
| 480 | * |
| 481 | * NOTE: |
| 482 | * |
| 483 | * Drivers that support gamma tables and also fbdev emulation through |
| 484 | * the provided helper library need to take care to fill out the gamma |
| 485 | * hooks for both. Currently there's a bit an unfortunate duplication |
| 486 | * going on, which should eventually be unified to just one set of |
| 487 | * hooks. |
| 488 | */ |
Maarten Lankhorst | 7ea7728 | 2016-06-07 12:49:30 +0200 | [diff] [blame] | 489 | int (*gamma_set)(struct drm_crtc *crtc, u16 *r, u16 *g, u16 *b, |
| 490 | uint32_t size); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 491 | |
| 492 | /** |
| 493 | * @destroy: |
| 494 | * |
| 495 | * Clean up plane resources. This is only called at driver unload time |
| 496 | * through drm_mode_config_cleanup() since a CRTC cannot be hotplugged |
| 497 | * in DRM. |
| 498 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 499 | void (*destroy)(struct drm_crtc *crtc); |
| 500 | |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 501 | /** |
| 502 | * @set_config: |
| 503 | * |
| 504 | * This is the main legacy entry point to change the modeset state on a |
| 505 | * CRTC. All the details of the desired configuration are passed in a |
| 506 | * struct &drm_mode_set - see there for details. |
| 507 | * |
| 508 | * Drivers implementing atomic modeset should use |
| 509 | * drm_atomic_helper_set_config() to implement this hook. |
| 510 | * |
| 511 | * RETURNS: |
| 512 | * |
| 513 | * 0 on success or a negative error code on failure. |
| 514 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 515 | int (*set_config)(struct drm_mode_set *set); |
Kristian Høgsberg | d91d8a3 | 2009-11-17 12:43:55 -0500 | [diff] [blame] | 516 | |
Daniel Vetter | f6da8c6 | 2015-12-04 09:46:00 +0100 | [diff] [blame] | 517 | /** |
| 518 | * @page_flip: |
| 519 | * |
| 520 | * Legacy entry point to schedule a flip to the given framebuffer. |
| 521 | * |
| 522 | * Page flipping is a synchronization mechanism that replaces the frame |
| 523 | * buffer being scanned out by the CRTC with a new frame buffer during |
| 524 | * vertical blanking, avoiding tearing (except when requested otherwise |
| 525 | * through the DRM_MODE_PAGE_FLIP_ASYNC flag). When an application |
| 526 | * requests a page flip the DRM core verifies that the new frame buffer |
| 527 | * is large enough to be scanned out by the CRTC in the currently |
| 528 | * configured mode and then calls the CRTC ->page_flip() operation with a |
| 529 | * pointer to the new frame buffer. |
| 530 | * |
| 531 | * The driver must wait for any pending rendering to the new framebuffer |
| 532 | * to complete before executing the flip. It should also wait for any |
| 533 | * pending rendering from other drivers if the underlying buffer is a |
| 534 | * shared dma-buf. |
| 535 | * |
| 536 | * An application can request to be notified when the page flip has |
| 537 | * completed. The drm core will supply a struct &drm_event in the event |
| 538 | * parameter in this case. This can be handled by the |
| 539 | * drm_crtc_send_vblank_event() function, which the driver should call on |
| 540 | * the provided event upon completion of the flip. Note that if |
| 541 | * the driver supports vblank signalling and timestamping the vblank |
| 542 | * counters and timestamps must agree with the ones returned from page |
| 543 | * flip events. With the current vblank helper infrastructure this can |
| 544 | * be achieved by holding a vblank reference while the page flip is |
| 545 | * pending, acquired through drm_crtc_vblank_get() and released with |
| 546 | * drm_crtc_vblank_put(). Drivers are free to implement their own vblank |
| 547 | * counter and timestamp tracking though, e.g. if they have accurate |
| 548 | * timestamp registers in hardware. |
| 549 | * |
| 550 | * FIXME: |
| 551 | * |
| 552 | * Up to that point drivers need to manage events themselves and can use |
| 553 | * even->base.list freely for that. Specifically they need to ensure |
| 554 | * that they don't send out page flip (or vblank) events for which the |
| 555 | * corresponding drm file has been closed already. The drm core |
| 556 | * unfortunately does not (yet) take care of that. Therefore drivers |
| 557 | * currently must clean up and release pending events in their |
| 558 | * ->preclose driver function. |
| 559 | * |
| 560 | * This callback is optional. |
| 561 | * |
| 562 | * NOTE: |
| 563 | * |
| 564 | * Very early versions of the KMS ABI mandated that the driver must |
| 565 | * block (but not reject) any rendering to the old framebuffer until the |
| 566 | * flip operation has completed and the old framebuffer is no longer |
| 567 | * visible. This requirement has been lifted, and userspace is instead |
| 568 | * expected to request delivery of an event and wait with recycling old |
| 569 | * buffers until such has been received. |
| 570 | * |
| 571 | * RETURNS: |
| 572 | * |
| 573 | * 0 on success or a negative error code on failure. Note that if a |
| 574 | * ->page_flip() operation is already pending the callback should return |
| 575 | * -EBUSY. Pageflips on a disabled CRTC (either by setting a NULL mode |
| 576 | * or just runtime disabled through DPMS respectively the new atomic |
Daniel Vetter | 4cba685 | 2015-12-08 09:49:20 +0100 | [diff] [blame] | 577 | * "ACTIVE" state) should result in an -EINVAL error code. Note that |
| 578 | * drm_atomic_helper_page_flip() checks this already for atomic drivers. |
Kristian Høgsberg | d91d8a3 | 2009-11-17 12:43:55 -0500 | [diff] [blame] | 579 | */ |
| 580 | int (*page_flip)(struct drm_crtc *crtc, |
| 581 | struct drm_framebuffer *fb, |
Keith Packard | ed8d197 | 2013-07-22 18:49:58 -0700 | [diff] [blame] | 582 | struct drm_pending_vblank_event *event, |
| 583 | uint32_t flags); |
Paulo Zanoni | bffd9de0 | 2012-05-15 18:09:05 -0300 | [diff] [blame] | 584 | |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 585 | /** |
| 586 | * @set_property: |
| 587 | * |
| 588 | * This is the legacy entry point to update a property attached to the |
| 589 | * CRTC. |
| 590 | * |
| 591 | * Drivers implementing atomic modeset should use |
| 592 | * drm_atomic_helper_crtc_set_property() to implement this hook. |
| 593 | * |
| 594 | * This callback is optional if the driver does not support any legacy |
| 595 | * driver-private properties. |
| 596 | * |
| 597 | * RETURNS: |
| 598 | * |
| 599 | * 0 on success or a negative error code on failure. |
| 600 | */ |
Paulo Zanoni | bffd9de0 | 2012-05-15 18:09:05 -0300 | [diff] [blame] | 601 | int (*set_property)(struct drm_crtc *crtc, |
| 602 | struct drm_property *property, uint64_t val); |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 603 | |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 604 | /** |
| 605 | * @atomic_duplicate_state: |
| 606 | * |
| 607 | * Duplicate the current atomic state for this CRTC and return it. |
| 608 | * The core and helpers gurantee that any atomic state duplicated with |
| 609 | * this hook and still owned by the caller (i.e. not transferred to the |
| 610 | * driver by calling ->atomic_commit() from struct |
| 611 | * &drm_mode_config_funcs) will be cleaned up by calling the |
| 612 | * @atomic_destroy_state hook in this structure. |
| 613 | * |
| 614 | * Atomic drivers which don't subclass struct &drm_crtc should use |
| 615 | * drm_atomic_helper_crtc_duplicate_state(). Drivers that subclass the |
| 616 | * state structure to extend it with driver-private state should use |
| 617 | * __drm_atomic_helper_crtc_duplicate_state() to make sure shared state is |
| 618 | * duplicated in a consistent fashion across drivers. |
| 619 | * |
| 620 | * It is an error to call this hook before crtc->state has been |
| 621 | * initialized correctly. |
| 622 | * |
| 623 | * NOTE: |
| 624 | * |
| 625 | * If the duplicate state references refcounted resources this hook must |
| 626 | * acquire a reference for each of them. The driver must release these |
| 627 | * references again in @atomic_destroy_state. |
| 628 | * |
| 629 | * RETURNS: |
| 630 | * |
| 631 | * Duplicated atomic state or NULL when the allocation failed. |
| 632 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 633 | struct drm_crtc_state *(*atomic_duplicate_state)(struct drm_crtc *crtc); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 634 | |
| 635 | /** |
| 636 | * @atomic_destroy_state: |
| 637 | * |
| 638 | * Destroy a state duplicated with @atomic_duplicate_state and release |
| 639 | * or unreference all resources it references |
| 640 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 641 | void (*atomic_destroy_state)(struct drm_crtc *crtc, |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 642 | struct drm_crtc_state *state); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 643 | |
| 644 | /** |
| 645 | * @atomic_set_property: |
| 646 | * |
| 647 | * Decode a driver-private property value and store the decoded value |
| 648 | * into the passed-in state structure. Since the atomic core decodes all |
| 649 | * standardized properties (even for extensions beyond the core set of |
| 650 | * properties which might not be implemented by all drivers) this |
| 651 | * requires drivers to subclass the state structure. |
| 652 | * |
| 653 | * Such driver-private properties should really only be implemented for |
| 654 | * truly hardware/vendor specific state. Instead it is preferred to |
| 655 | * standardize atomic extension and decode the properties used to expose |
| 656 | * such an extension in the core. |
| 657 | * |
| 658 | * Do not call this function directly, use |
| 659 | * drm_atomic_crtc_set_property() instead. |
| 660 | * |
| 661 | * This callback is optional if the driver does not support any |
| 662 | * driver-private atomic properties. |
| 663 | * |
| 664 | * NOTE: |
| 665 | * |
| 666 | * This function is called in the state assembly phase of atomic |
| 667 | * modesets, which can be aborted for any reason (including on |
| 668 | * userspace's request to just check whether a configuration would be |
| 669 | * possible). Drivers MUST NOT touch any persistent state (hardware or |
| 670 | * software) or data structures except the passed in @state parameter. |
| 671 | * |
| 672 | * Also since userspace controls in which order properties are set this |
| 673 | * function must not do any input validation (since the state update is |
| 674 | * incomplete and hence likely inconsistent). Instead any such input |
| 675 | * validation must be done in the various atomic_check callbacks. |
| 676 | * |
| 677 | * RETURNS: |
| 678 | * |
| 679 | * 0 if the property has been found, -EINVAL if the property isn't |
| 680 | * implemented by the driver (which should never happen, the core only |
| 681 | * asks for properties attached to this CRTC). No other validation is |
| 682 | * allowed by the driver. The core already checks that the property |
| 683 | * value is within the range (integer, valid enum value, ...) the driver |
| 684 | * set when registering the property. |
| 685 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 686 | int (*atomic_set_property)(struct drm_crtc *crtc, |
| 687 | struct drm_crtc_state *state, |
| 688 | struct drm_property *property, |
| 689 | uint64_t val); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 690 | /** |
| 691 | * @atomic_get_property: |
| 692 | * |
| 693 | * Reads out the decoded driver-private property. This is used to |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 694 | * implement the GETCRTC IOCTL. |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 695 | * |
| 696 | * Do not call this function directly, use |
| 697 | * drm_atomic_crtc_get_property() instead. |
| 698 | * |
| 699 | * This callback is optional if the driver does not support any |
| 700 | * driver-private atomic properties. |
| 701 | * |
| 702 | * RETURNS: |
| 703 | * |
| 704 | * 0 on success, -EINVAL if the property isn't implemented by the |
| 705 | * driver (which should never happen, the core only asks for |
| 706 | * properties attached to this CRTC). |
| 707 | */ |
Rob Clark | ac9c925 | 2014-12-18 16:01:47 -0500 | [diff] [blame] | 708 | int (*atomic_get_property)(struct drm_crtc *crtc, |
| 709 | const struct drm_crtc_state *state, |
| 710 | struct drm_property *property, |
| 711 | uint64_t *val); |
Benjamin Gaignard | 79190ea | 2016-06-21 16:37:09 +0200 | [diff] [blame] | 712 | |
| 713 | /** |
| 714 | * @late_register: |
| 715 | * |
| 716 | * This optional hook can be used to register additional userspace |
| 717 | * interfaces attached to the crtc like debugfs interfaces. |
| 718 | * It is called late in the driver load sequence from drm_dev_register(). |
| 719 | * Everything added from this callback should be unregistered in |
| 720 | * the early_unregister callback. |
| 721 | * |
| 722 | * Returns: |
| 723 | * |
| 724 | * 0 on success, or a negative error code on failure. |
| 725 | */ |
| 726 | int (*late_register)(struct drm_crtc *crtc); |
| 727 | |
| 728 | /** |
| 729 | * @early_unregister: |
| 730 | * |
| 731 | * This optional hook should be used to unregister the additional |
| 732 | * userspace interfaces attached to the crtc from |
| 733 | * late_unregister(). It is called from drm_dev_unregister(), |
| 734 | * early in the driver unload sequence to disable userspace access |
| 735 | * before data structures are torndown. |
| 736 | */ |
| 737 | void (*early_unregister)(struct drm_crtc *crtc); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 738 | }; |
| 739 | |
| 740 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 741 | * struct drm_crtc - central CRTC control structure |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 742 | * @dev: parent DRM device |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 743 | * @port: OF node used by drm_of_find_possible_crtcs() |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 744 | * @head: list management |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 745 | * @name: human readable name, can be overwritten by the driver |
Rob Clark | 51fd371 | 2013-11-19 12:10:12 -0500 | [diff] [blame] | 746 | * @mutex: per-CRTC locking |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 747 | * @base: base KMS object for ID tracking etc. |
Matt Roper | e13161a | 2014-04-01 15:22:38 -0700 | [diff] [blame] | 748 | * @primary: primary plane for this CRTC |
| 749 | * @cursor: cursor plane for this CRTC |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 750 | * @cursor_x: current x position of the cursor, used for universal cursor planes |
| 751 | * @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] | 752 | * @enabled: is this CRTC enabled? |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 753 | * @mode: current mode timings |
| 754 | * @hwmode: mode timings as programmed to hw regs |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 755 | * @x: x position on screen |
| 756 | * @y: y position on screen |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 757 | * @funcs: CRTC control functions |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 758 | * @gamma_size: size of gamma ramp |
| 759 | * @gamma_store: gamma ramp values |
Jesse Barnes | 7749163 | 2011-11-07 12:03:14 -0800 | [diff] [blame] | 760 | * @helper_private: mid-layer private data |
Paulo Zanoni | bffd9de0 | 2012-05-15 18:09:05 -0300 | [diff] [blame] | 761 | * @properties: property tracking for this CRTC |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 762 | * |
| 763 | * Each CRTC may have one or more connectors associated with it. This structure |
| 764 | * allows the CRTC to be controlled. |
| 765 | */ |
| 766 | struct drm_crtc { |
| 767 | struct drm_device *dev; |
Russell King | 7e435aa | 2014-06-15 11:07:12 +0100 | [diff] [blame] | 768 | struct device_node *port; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 769 | struct list_head head; |
| 770 | |
Ville Syrjälä | fa3ab4c | 2015-12-08 18:41:53 +0200 | [diff] [blame] | 771 | char *name; |
| 772 | |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 773 | /** |
| 774 | * @mutex: |
Daniel Vetter | 29494c1 | 2012-12-02 02:18:25 +0100 | [diff] [blame] | 775 | * |
| 776 | * This provides a read lock for the overall crtc state (mode, dpms |
| 777 | * state, ...) and a write lock for everything which can be update |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 778 | * without a full modeset (fb, cursor data, crtc properties ...). Full |
| 779 | * modeset also need to grab dev->mode_config.connection_mutex. |
Daniel Vetter | 29494c1 | 2012-12-02 02:18:25 +0100 | [diff] [blame] | 780 | */ |
Rob Clark | 51fd371 | 2013-11-19 12:10:12 -0500 | [diff] [blame] | 781 | struct drm_modeset_lock mutex; |
Daniel Vetter | 29494c1 | 2012-12-02 02:18:25 +0100 | [diff] [blame] | 782 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 783 | struct drm_mode_object base; |
| 784 | |
Matt Roper | e13161a | 2014-04-01 15:22:38 -0700 | [diff] [blame] | 785 | /* primary and cursor planes for CRTC */ |
| 786 | struct drm_plane *primary; |
| 787 | struct drm_plane *cursor; |
| 788 | |
Daniel Vetter | 9609408 | 2016-07-15 21:47:59 +0200 | [diff] [blame] | 789 | /** |
| 790 | * @index: Position inside the mode_config.list, can be used as an array |
| 791 | * index. It is invariant over the lifetime of the CRTC. |
| 792 | */ |
Chris Wilson | 490d3d1 | 2016-05-27 20:05:00 +0100 | [diff] [blame] | 793 | unsigned index; |
| 794 | |
Matt Roper | 161d0dc | 2014-06-10 08:28:10 -0700 | [diff] [blame] | 795 | /* position of cursor plane on crtc */ |
| 796 | int cursor_x; |
| 797 | int cursor_y; |
| 798 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 799 | bool enabled; |
| 800 | |
Mario Kleiner | 27641c3 | 2010-10-23 04:20:23 +0200 | [diff] [blame] | 801 | /* Requested mode from modesetting. */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 802 | struct drm_display_mode mode; |
| 803 | |
Mario Kleiner | 27641c3 | 2010-10-23 04:20:23 +0200 | [diff] [blame] | 804 | /* Programmed mode in hw, after adjustments for encoders, |
| 805 | * crtc, panel scaling etc. Needed for timestamping etc. |
| 806 | */ |
| 807 | struct drm_display_mode hwmode; |
| 808 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 809 | int x, y; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 810 | const struct drm_crtc_funcs *funcs; |
| 811 | |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 812 | /* Legacy FB CRTC gamma size for reporting to userspace */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 813 | uint32_t gamma_size; |
| 814 | uint16_t *gamma_store; |
| 815 | |
| 816 | /* if you are using the helper */ |
Daniel Vetter | 4490d4c | 2015-12-04 09:45:45 +0100 | [diff] [blame] | 817 | const struct drm_crtc_helper_funcs *helper_private; |
Paulo Zanoni | bffd9de0 | 2012-05-15 18:09:05 -0300 | [diff] [blame] | 818 | |
| 819 | struct drm_object_properties properties; |
Daniel Vetter | d059f65 | 2014-07-25 18:07:40 +0200 | [diff] [blame] | 820 | |
Daniel Vetter | 3b24f7d | 2016-06-08 14:19:00 +0200 | [diff] [blame] | 821 | /** |
| 822 | * @state: |
| 823 | * |
| 824 | * Current atomic state for this CRTC. |
| 825 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 826 | struct drm_crtc_state *state; |
| 827 | |
Daniel Vetter | 3b24f7d | 2016-06-08 14:19:00 +0200 | [diff] [blame] | 828 | /** |
| 829 | * @commit_list: |
| 830 | * |
| 831 | * List of &drm_crtc_commit structures tracking pending commits. |
| 832 | * Protected by @commit_lock. This list doesn't hold its own full |
| 833 | * reference, but burrows it from the ongoing commit. Commit entries |
| 834 | * must be removed from this list once the commit is fully completed, |
| 835 | * but before it's correspoding &drm_atomic_state gets destroyed. |
| 836 | */ |
| 837 | struct list_head commit_list; |
| 838 | |
| 839 | /** |
| 840 | * @commit_lock: |
| 841 | * |
| 842 | * Spinlock to protect @commit_list. |
| 843 | */ |
| 844 | spinlock_t commit_lock; |
| 845 | |
| 846 | /** |
| 847 | * @acquire_ctx: |
| 848 | * |
| 849 | * Per-CRTC implicit acquire context used by atomic drivers for legacy |
| 850 | * IOCTLs, so that atomic drivers can get at the locking acquire |
| 851 | * context. |
Daniel Vetter | d059f65 | 2014-07-25 18:07:40 +0200 | [diff] [blame] | 852 | */ |
| 853 | struct drm_modeset_acquire_ctx *acquire_ctx; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 854 | }; |
| 855 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 856 | /** |
| 857 | * struct drm_connector_state - mutable connector state |
Daniel Vetter | 07cc0ef | 2014-11-27 15:49:39 +0100 | [diff] [blame] | 858 | * @connector: backpointer to the connector |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 859 | * @crtc: CRTC to connect connector to, NULL if disabled |
Daniel Vetter | 623369e | 2014-09-16 17:50:47 +0200 | [diff] [blame] | 860 | * @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] | 861 | * @state: backpointer to global drm_atomic_state |
| 862 | */ |
| 863 | struct drm_connector_state { |
Daniel Vetter | 07cc0ef | 2014-11-27 15:49:39 +0100 | [diff] [blame] | 864 | struct drm_connector *connector; |
| 865 | |
Rob Clark | 6ddd388 | 2014-11-21 15:28:31 -0500 | [diff] [blame] | 866 | 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] | 867 | |
Daniel Vetter | 623369e | 2014-09-16 17:50:47 +0200 | [diff] [blame] | 868 | struct drm_encoder *best_encoder; |
| 869 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 870 | struct drm_atomic_state *state; |
| 871 | }; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 872 | |
| 873 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 874 | * struct drm_connector_funcs - control connectors on a given device |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 875 | * |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 876 | * Each CRTC may have one or more connectors attached to it. The functions |
| 877 | * below allow the core DRM code to control connectors, enumerate available modes, |
| 878 | * etc. |
| 879 | */ |
| 880 | struct drm_connector_funcs { |
Daniel Vetter | 6fe14ac | 2015-12-04 09:45:58 +0100 | [diff] [blame] | 881 | /** |
| 882 | * @dpms: |
| 883 | * |
| 884 | * Legacy entry point to set the per-connector DPMS state. Legacy DPMS |
| 885 | * is exposed as a standard property on the connector, but diverted to |
| 886 | * this callback in the drm core. Note that atomic drivers don't |
| 887 | * implement the 4 level DPMS support on the connector any more, but |
| 888 | * instead only have an on/off "ACTIVE" property on the CRTC object. |
| 889 | * |
| 890 | * Drivers implementing atomic modeset should use |
| 891 | * drm_atomic_helper_connector_dpms() to implement this hook. |
| 892 | * |
| 893 | * RETURNS: |
| 894 | * |
| 895 | * 0 on success or a negative error code on failure. |
| 896 | */ |
Maarten Lankhorst | 9a69a9a | 2015-07-21 11:34:55 +0200 | [diff] [blame] | 897 | int (*dpms)(struct drm_connector *connector, int mode); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 898 | |
| 899 | /** |
| 900 | * @reset: |
| 901 | * |
| 902 | * Reset connector hardware and software state to off. This function isn't |
| 903 | * called by the core directly, only through drm_mode_config_reset(). |
| 904 | * It's not a helper hook only for historical reasons. |
| 905 | * |
| 906 | * Atomic drivers can use drm_atomic_helper_connector_reset() to reset |
| 907 | * atomic state using this hook. |
| 908 | */ |
Chris Wilson | eb03355 | 2011-01-24 15:11:08 +0000 | [diff] [blame] | 909 | void (*reset)(struct drm_connector *connector); |
Chris Wilson | 930a9e2 | 2010-09-14 11:07:23 +0100 | [diff] [blame] | 910 | |
Daniel Vetter | 6fe14ac | 2015-12-04 09:45:58 +0100 | [diff] [blame] | 911 | /** |
| 912 | * @detect: |
| 913 | * |
| 914 | * Check to see if anything is attached to the connector. The parameter |
| 915 | * force is set to false whilst polling, true when checking the |
| 916 | * connector due to a user request. force can be used by the driver to |
| 917 | * avoid expensive, destructive operations during automated probing. |
| 918 | * |
| 919 | * FIXME: |
| 920 | * |
| 921 | * Note that this hook is only called by the probe helper. It's not in |
| 922 | * the helper library vtable purely for historical reasons. The only DRM |
| 923 | * core entry point to probe connector state is @fill_modes. |
| 924 | * |
| 925 | * RETURNS: |
| 926 | * |
| 927 | * drm_connector_status indicating the connector's status. |
Chris Wilson | 930a9e2 | 2010-09-14 11:07:23 +0100 | [diff] [blame] | 928 | */ |
Chris Wilson | 7b334fc | 2010-09-09 23:51:02 +0100 | [diff] [blame] | 929 | enum drm_connector_status (*detect)(struct drm_connector *connector, |
Chris Wilson | 930a9e2 | 2010-09-14 11:07:23 +0100 | [diff] [blame] | 930 | bool force); |
Daniel Vetter | 6fe14ac | 2015-12-04 09:45:58 +0100 | [diff] [blame] | 931 | |
| 932 | /** |
| 933 | * @force: |
| 934 | * |
| 935 | * This function is called to update internal encoder state when the |
| 936 | * connector is forced to a certain state by userspace, either through |
| 937 | * the sysfs interfaces or on the kernel cmdline. In that case the |
| 938 | * @detect callback isn't called. |
| 939 | * |
| 940 | * FIXME: |
| 941 | * |
| 942 | * Note that this hook is only called by the probe helper. It's not in |
| 943 | * the helper library vtable purely for historical reasons. The only DRM |
| 944 | * core entry point to probe connector state is @fill_modes. |
| 945 | */ |
| 946 | void (*force)(struct drm_connector *connector); |
| 947 | |
| 948 | /** |
| 949 | * @fill_modes: |
| 950 | * |
| 951 | * Entry point for output detection and basic mode validation. The |
| 952 | * driver should reprobe the output if needed (e.g. when hotplug |
| 953 | * handling is unreliable), add all detected modes to connector->modes |
| 954 | * and filter out any the device can't support in any configuration. It |
| 955 | * also needs to filter out any modes wider or higher than the |
| 956 | * parameters max_width and max_height indicate. |
| 957 | * |
| 958 | * The drivers must also prune any modes no longer valid from |
| 959 | * connector->modes. Furthermore it must update connector->status and |
| 960 | * connector->edid. If no EDID has been received for this output |
| 961 | * connector->edid must be NULL. |
| 962 | * |
| 963 | * Drivers using the probe helpers should use |
| 964 | * drm_helper_probe_single_connector_modes() or |
| 965 | * drm_helper_probe_single_connector_modes_nomerge() to implement this |
| 966 | * function. |
| 967 | * |
| 968 | * RETURNS: |
| 969 | * |
| 970 | * The number of modes detected and filled into connector->modes. |
| 971 | */ |
Jesse Barnes | 40a518d | 2009-01-12 12:05:32 -0800 | [diff] [blame] | 972 | 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] | 973 | |
| 974 | /** |
| 975 | * @set_property: |
| 976 | * |
| 977 | * This is the legacy entry point to update a property attached to the |
| 978 | * connector. |
| 979 | * |
| 980 | * Drivers implementing atomic modeset should use |
| 981 | * drm_atomic_helper_connector_set_property() to implement this hook. |
| 982 | * |
| 983 | * This callback is optional if the driver does not support any legacy |
| 984 | * driver-private properties. |
| 985 | * |
| 986 | * RETURNS: |
| 987 | * |
| 988 | * 0 on success or a negative error code on failure. |
| 989 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 990 | int (*set_property)(struct drm_connector *connector, struct drm_property *property, |
| 991 | uint64_t val); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 992 | |
| 993 | /** |
Chris Wilson | aaf285e | 2016-06-15 13:17:47 +0100 | [diff] [blame] | 994 | * @late_register: |
| 995 | * |
| 996 | * This optional hook can be used to register additional userspace |
| 997 | * interfaces attached to the connector, light backlight control, i2c, |
| 998 | * DP aux or similar interfaces. It is called late in the driver load |
| 999 | * sequence from drm_connector_register() when registering all the |
| 1000 | * core drm connector interfaces. Everything added from this callback |
| 1001 | * should be unregistered in the early_unregister callback. |
| 1002 | * |
| 1003 | * Returns: |
| 1004 | * |
| 1005 | * 0 on success, or a negative error code on failure. |
| 1006 | */ |
| 1007 | int (*late_register)(struct drm_connector *connector); |
| 1008 | |
| 1009 | /** |
| 1010 | * @early_unregister: |
| 1011 | * |
| 1012 | * This optional hook should be used to unregister the additional |
| 1013 | * userspace interfaces attached to the connector from |
| 1014 | * late_unregister(). It is called from drm_connector_unregister(), |
| 1015 | * early in the driver unload sequence to disable userspace access |
| 1016 | * before data structures are torndown. |
| 1017 | */ |
| 1018 | void (*early_unregister)(struct drm_connector *connector); |
| 1019 | |
| 1020 | /** |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1021 | * @destroy: |
| 1022 | * |
| 1023 | * Clean up connector resources. This is called at driver unload time |
| 1024 | * through drm_mode_config_cleanup(). It can also be called at runtime |
| 1025 | * when a connector is being hot-unplugged for drivers that support |
| 1026 | * connector hotplugging (e.g. DisplayPort MST). |
| 1027 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1028 | void (*destroy)(struct drm_connector *connector); |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1029 | |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1030 | /** |
| 1031 | * @atomic_duplicate_state: |
| 1032 | * |
| 1033 | * Duplicate the current atomic state for this connector and return it. |
| 1034 | * The core and helpers gurantee that any atomic state duplicated with |
| 1035 | * this hook and still owned by the caller (i.e. not transferred to the |
| 1036 | * driver by calling ->atomic_commit() from struct |
| 1037 | * &drm_mode_config_funcs) will be cleaned up by calling the |
| 1038 | * @atomic_destroy_state hook in this structure. |
| 1039 | * |
| 1040 | * Atomic drivers which don't subclass struct &drm_connector_state should use |
| 1041 | * drm_atomic_helper_connector_duplicate_state(). Drivers that subclass the |
| 1042 | * state structure to extend it with driver-private state should use |
| 1043 | * __drm_atomic_helper_connector_duplicate_state() to make sure shared state is |
| 1044 | * duplicated in a consistent fashion across drivers. |
| 1045 | * |
| 1046 | * It is an error to call this hook before connector->state has been |
| 1047 | * initialized correctly. |
| 1048 | * |
| 1049 | * NOTE: |
| 1050 | * |
| 1051 | * If the duplicate state references refcounted resources this hook must |
| 1052 | * acquire a reference for each of them. The driver must release these |
| 1053 | * references again in @atomic_destroy_state. |
| 1054 | * |
| 1055 | * RETURNS: |
| 1056 | * |
| 1057 | * Duplicated atomic state or NULL when the allocation failed. |
| 1058 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1059 | struct drm_connector_state *(*atomic_duplicate_state)(struct drm_connector *connector); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1060 | |
| 1061 | /** |
| 1062 | * @atomic_destroy_state: |
| 1063 | * |
| 1064 | * Destroy a state duplicated with @atomic_duplicate_state and release |
| 1065 | * or unreference all resources it references |
| 1066 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1067 | void (*atomic_destroy_state)(struct drm_connector *connector, |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1068 | struct drm_connector_state *state); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1069 | |
| 1070 | /** |
| 1071 | * @atomic_set_property: |
| 1072 | * |
| 1073 | * Decode a driver-private property value and store the decoded value |
| 1074 | * into the passed-in state structure. Since the atomic core decodes all |
| 1075 | * standardized properties (even for extensions beyond the core set of |
| 1076 | * properties which might not be implemented by all drivers) this |
| 1077 | * requires drivers to subclass the state structure. |
| 1078 | * |
| 1079 | * Such driver-private properties should really only be implemented for |
| 1080 | * truly hardware/vendor specific state. Instead it is preferred to |
| 1081 | * standardize atomic extension and decode the properties used to expose |
| 1082 | * such an extension in the core. |
| 1083 | * |
| 1084 | * Do not call this function directly, use |
| 1085 | * drm_atomic_connector_set_property() instead. |
| 1086 | * |
| 1087 | * This callback is optional if the driver does not support any |
| 1088 | * driver-private atomic properties. |
| 1089 | * |
| 1090 | * NOTE: |
| 1091 | * |
| 1092 | * This function is called in the state assembly phase of atomic |
| 1093 | * modesets, which can be aborted for any reason (including on |
| 1094 | * userspace's request to just check whether a configuration would be |
| 1095 | * possible). Drivers MUST NOT touch any persistent state (hardware or |
| 1096 | * software) or data structures except the passed in @state parameter. |
| 1097 | * |
| 1098 | * Also since userspace controls in which order properties are set this |
| 1099 | * function must not do any input validation (since the state update is |
| 1100 | * incomplete and hence likely inconsistent). Instead any such input |
| 1101 | * validation must be done in the various atomic_check callbacks. |
| 1102 | * |
| 1103 | * RETURNS: |
| 1104 | * |
| 1105 | * 0 if the property has been found, -EINVAL if the property isn't |
| 1106 | * implemented by the driver (which shouldn't ever happen, the core only |
| 1107 | * asks for properties attached to this connector). No other validation |
| 1108 | * is allowed by the driver. The core already checks that the property |
| 1109 | * value is within the range (integer, valid enum value, ...) the driver |
| 1110 | * set when registering the property. |
| 1111 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1112 | int (*atomic_set_property)(struct drm_connector *connector, |
| 1113 | struct drm_connector_state *state, |
| 1114 | struct drm_property *property, |
| 1115 | uint64_t val); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1116 | |
| 1117 | /** |
| 1118 | * @atomic_get_property: |
| 1119 | * |
| 1120 | * Reads out the decoded driver-private property. This is used to |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 1121 | * implement the GETCONNECTOR IOCTL. |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1122 | * |
| 1123 | * Do not call this function directly, use |
| 1124 | * drm_atomic_connector_get_property() instead. |
| 1125 | * |
| 1126 | * This callback is optional if the driver does not support any |
| 1127 | * driver-private atomic properties. |
| 1128 | * |
| 1129 | * RETURNS: |
| 1130 | * |
| 1131 | * 0 on success, -EINVAL if the property isn't implemented by the |
| 1132 | * driver (which shouldn't ever happen, the core only asks for |
| 1133 | * properties attached to this connector). |
| 1134 | */ |
Rob Clark | ac9c925 | 2014-12-18 16:01:47 -0500 | [diff] [blame] | 1135 | int (*atomic_get_property)(struct drm_connector *connector, |
| 1136 | const struct drm_connector_state *state, |
| 1137 | struct drm_property *property, |
| 1138 | uint64_t *val); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1139 | }; |
| 1140 | |
Jesse Barnes | 6c3db92 | 2011-11-07 12:03:16 -0800 | [diff] [blame] | 1141 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 1142 | * struct drm_encoder_funcs - encoder controls |
Jesse Barnes | 6c3db92 | 2011-11-07 12:03:16 -0800 | [diff] [blame] | 1143 | * |
| 1144 | * Encoders sit between CRTCs and connectors. |
| 1145 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1146 | struct drm_encoder_funcs { |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1147 | /** |
| 1148 | * @reset: |
| 1149 | * |
| 1150 | * Reset encoder hardware and software state to off. This function isn't |
| 1151 | * called by the core directly, only through drm_mode_config_reset(). |
| 1152 | * It's not a helper hook only for historical reasons. |
| 1153 | */ |
Chris Wilson | eb03355 | 2011-01-24 15:11:08 +0000 | [diff] [blame] | 1154 | void (*reset)(struct drm_encoder *encoder); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1155 | |
| 1156 | /** |
| 1157 | * @destroy: |
| 1158 | * |
| 1159 | * Clean up encoder resources. This is only called at driver unload time |
| 1160 | * through drm_mode_config_cleanup() since an encoder cannot be |
| 1161 | * hotplugged in DRM. |
| 1162 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1163 | void (*destroy)(struct drm_encoder *encoder); |
Benjamin Gaignard | 79190ea | 2016-06-21 16:37:09 +0200 | [diff] [blame] | 1164 | |
| 1165 | /** |
| 1166 | * @late_register: |
| 1167 | * |
| 1168 | * This optional hook can be used to register additional userspace |
| 1169 | * interfaces attached to the encoder like debugfs interfaces. |
| 1170 | * It is called late in the driver load sequence from drm_dev_register(). |
| 1171 | * Everything added from this callback should be unregistered in |
| 1172 | * the early_unregister callback. |
| 1173 | * |
| 1174 | * Returns: |
| 1175 | * |
| 1176 | * 0 on success, or a negative error code on failure. |
| 1177 | */ |
| 1178 | int (*late_register)(struct drm_encoder *encoder); |
| 1179 | |
| 1180 | /** |
| 1181 | * @early_unregister: |
| 1182 | * |
| 1183 | * This optional hook should be used to unregister the additional |
| 1184 | * userspace interfaces attached to the encoder from |
| 1185 | * late_unregister(). It is called from drm_dev_unregister(), |
| 1186 | * early in the driver unload sequence to disable userspace access |
| 1187 | * before data structures are torndown. |
| 1188 | */ |
| 1189 | void (*early_unregister)(struct drm_encoder *encoder); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1190 | }; |
| 1191 | |
Ben Skeggs | afe887d | 2012-01-12 16:00:57 +1000 | [diff] [blame] | 1192 | #define DRM_CONNECTOR_MAX_ENCODER 3 |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1193 | |
| 1194 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 1195 | * struct drm_encoder - central DRM encoder structure |
Jesse Barnes | db3e449 | 2011-11-07 12:03:17 -0800 | [diff] [blame] | 1196 | * @dev: parent DRM device |
| 1197 | * @head: list management |
| 1198 | * @base: base KMS object |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 1199 | * @name: human readable name, can be overwritten by the driver |
Jesse Barnes | db3e449 | 2011-11-07 12:03:17 -0800 | [diff] [blame] | 1200 | * @encoder_type: one of the %DRM_MODE_ENCODER_<foo> types in drm_mode.h |
| 1201 | * @possible_crtcs: bitmask of potential CRTC bindings |
| 1202 | * @possible_clones: bitmask of potential sibling encoders for cloning |
| 1203 | * @crtc: currently bound CRTC |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1204 | * @bridge: bridge associated to the encoder |
Jesse Barnes | db3e449 | 2011-11-07 12:03:17 -0800 | [diff] [blame] | 1205 | * @funcs: control functions |
| 1206 | * @helper_private: mid-layer private data |
| 1207 | * |
| 1208 | * CRTCs drive pixels to encoders, which convert them into signals |
| 1209 | * appropriate for a given connector or set of connectors. |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1210 | */ |
| 1211 | struct drm_encoder { |
| 1212 | struct drm_device *dev; |
| 1213 | struct list_head head; |
| 1214 | |
| 1215 | struct drm_mode_object base; |
Jani Nikula | e574894 | 2014-05-14 16:58:20 +0300 | [diff] [blame] | 1216 | char *name; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1217 | int encoder_type; |
Chris Wilson | 490d3d1 | 2016-05-27 20:05:00 +0100 | [diff] [blame] | 1218 | |
Daniel Vetter | 9609408 | 2016-07-15 21:47:59 +0200 | [diff] [blame] | 1219 | /** |
| 1220 | * @index: Position inside the mode_config.list, can be used as an array |
| 1221 | * index. It is invariant over the lifetime of the encoder. |
| 1222 | */ |
Chris Wilson | 490d3d1 | 2016-05-27 20:05:00 +0100 | [diff] [blame] | 1223 | unsigned index; |
| 1224 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1225 | uint32_t possible_crtcs; |
| 1226 | uint32_t possible_clones; |
| 1227 | |
| 1228 | struct drm_crtc *crtc; |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1229 | struct drm_bridge *bridge; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1230 | const struct drm_encoder_funcs *funcs; |
Daniel Vetter | 4490d4c | 2015-12-04 09:45:45 +0100 | [diff] [blame] | 1231 | const struct drm_encoder_helper_funcs *helper_private; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1232 | }; |
| 1233 | |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 1234 | /* should we poll this connector for connects and disconnects */ |
| 1235 | /* hot plug detectable */ |
| 1236 | #define DRM_CONNECTOR_POLL_HPD (1 << 0) |
| 1237 | /* poll for connections */ |
| 1238 | #define DRM_CONNECTOR_POLL_CONNECT (1 << 1) |
| 1239 | /* can cleanly poll for disconnections without flickering the screen */ |
| 1240 | /* DACs should rarely do this without a lot of testing */ |
| 1241 | #define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2) |
| 1242 | |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 1243 | #define MAX_ELD_BYTES 128 |
| 1244 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1245 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 1246 | * struct drm_connector - central DRM connector control structure |
Jesse Barnes | 7225254 | 2011-11-07 12:03:18 -0800 | [diff] [blame] | 1247 | * @dev: parent DRM device |
| 1248 | * @kdev: kernel device for sysfs attributes |
| 1249 | * @attr: sysfs attributes |
| 1250 | * @head: list management |
| 1251 | * @base: base KMS object |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 1252 | * @name: human readable name, can be overwritten by the driver |
Jesse Barnes | 7225254 | 2011-11-07 12:03:18 -0800 | [diff] [blame] | 1253 | * @connector_type: one of the %DRM_MODE_CONNECTOR_<foo> types from drm_mode.h |
| 1254 | * @connector_type_id: index into connector type enum |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1255 | * @interlace_allowed: can this connector handle interlaced modes? |
| 1256 | * @doublescan_allowed: can this connector handle doublescan? |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1257 | * @stereo_allowed: can this connector handle stereo modes? |
Chris Wilson | 40daac6 | 2016-06-15 13:17:48 +0100 | [diff] [blame] | 1258 | * @registered: is this connector exposed (registered) with userspace? |
Jesse Barnes | 7225254 | 2011-11-07 12:03:18 -0800 | [diff] [blame] | 1259 | * @modes: modes available on this connector (from fill_modes() + user) |
| 1260 | * @status: one of the drm_connector_status enums (connected, not, or unknown) |
| 1261 | * @probed_modes: list of modes derived directly from the display |
| 1262 | * @display_info: information about attached display (e.g. from EDID) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1263 | * @funcs: connector control functions |
Jesse Barnes | 7225254 | 2011-11-07 12:03:18 -0800 | [diff] [blame] | 1264 | * @edid_blob_ptr: DRM property containing EDID if present |
Paulo Zanoni | 7e3bdf4 | 2012-05-15 18:09:01 -0300 | [diff] [blame] | 1265 | * @properties: property tracking for this connector |
Jesse Barnes | 7225254 | 2011-11-07 12:03:18 -0800 | [diff] [blame] | 1266 | * @polled: a %DRM_CONNECTOR_POLL_<foo> value for core driven polling |
| 1267 | * @dpms: current dpms state |
| 1268 | * @helper_private: mid-layer private data |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1269 | * @cmdline_mode: mode line parsed from the kernel cmdline for this connector |
Jesse Barnes | 7225254 | 2011-11-07 12:03:18 -0800 | [diff] [blame] | 1270 | * @force: a %DRM_FORCE_<foo> state for forced mode sets |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1271 | * @override_edid: has the EDID been overwritten through debugfs for testing? |
Jesse Barnes | 7225254 | 2011-11-07 12:03:18 -0800 | [diff] [blame] | 1272 | * @encoder_ids: valid encoders for this connector |
| 1273 | * @encoder: encoder driving this connector, if any |
| 1274 | * @eld: EDID-like data, if present |
| 1275 | * @dvi_dual: dual link DVI, if found |
| 1276 | * @max_tmds_clock: max clock rate, if found |
| 1277 | * @latency_present: AV delay info from ELD, if found |
| 1278 | * @video_latency: video latency info from ELD, if found |
| 1279 | * @audio_latency: audio latency info from ELD, if found |
| 1280 | * @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] | 1281 | * @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] | 1282 | * @edid_corrupt: indicates whether the last read EDID was corrupt |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1283 | * @debugfs_entry: debugfs directory for this connector |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1284 | * @state: current atomic state for this connector |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 1285 | * @has_tile: is this connector connected to a tiled monitor |
| 1286 | * @tile_group: tile group for the connected monitor |
| 1287 | * @tile_is_single_monitor: whether the tile is one monitor housing |
| 1288 | * @num_h_tile: number of horizontal tiles in the tile group |
| 1289 | * @num_v_tile: number of vertical tiles in the tile group |
| 1290 | * @tile_h_loc: horizontal location of this tile |
| 1291 | * @tile_v_loc: vertical location of this tile |
| 1292 | * @tile_h_size: horizontal size of this tile. |
| 1293 | * @tile_v_size: vertical size of this tile. |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1294 | * |
| 1295 | * Each connector may be connected to one or more CRTCs, or may be clonable by |
| 1296 | * another connector if they can share a CRTC. Each connector also has a specific |
| 1297 | * position in the broader display (referred to as a 'screen' though it could |
| 1298 | * span multiple monitors). |
| 1299 | */ |
| 1300 | struct drm_connector { |
| 1301 | struct drm_device *dev; |
Dave Airlie | 5bdebb1 | 2013-10-11 14:07:25 +1000 | [diff] [blame] | 1302 | struct device *kdev; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1303 | struct device_attribute *attr; |
| 1304 | struct list_head head; |
| 1305 | |
| 1306 | struct drm_mode_object base; |
| 1307 | |
Jani Nikula | 2abdd31 | 2014-05-14 16:58:19 +0300 | [diff] [blame] | 1308 | char *name; |
Daniel Vetter | 6942559 | 2016-07-19 18:25:01 +0200 | [diff] [blame] | 1309 | |
| 1310 | /** |
| 1311 | * @index: Compacted connector index, which matches the position inside |
| 1312 | * the mode_config.list for drivers not supporting hot-add/removing. Can |
| 1313 | * be used as an array index. It is invariant over the lifetime of the |
| 1314 | * connector. |
| 1315 | */ |
| 1316 | unsigned index; |
| 1317 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1318 | int connector_type; |
| 1319 | int connector_type_id; |
| 1320 | bool interlace_allowed; |
| 1321 | bool doublescan_allowed; |
Damien Lespiau | 560a067 | 2013-09-25 16:45:29 +0100 | [diff] [blame] | 1322 | bool stereo_allowed; |
Chris Wilson | 40daac6 | 2016-06-15 13:17:48 +0100 | [diff] [blame] | 1323 | bool registered; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1324 | struct list_head modes; /* list of modes on this connector */ |
| 1325 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1326 | enum drm_connector_status status; |
| 1327 | |
| 1328 | /* these are modes added by probing with DDC or the BIOS */ |
| 1329 | struct list_head probed_modes; |
| 1330 | |
| 1331 | struct drm_display_info display_info; |
| 1332 | const struct drm_connector_funcs *funcs; |
| 1333 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1334 | struct drm_property_blob *edid_blob_ptr; |
Paulo Zanoni | 7e3bdf4 | 2012-05-15 18:09:01 -0300 | [diff] [blame] | 1335 | struct drm_object_properties properties; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1336 | |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 1337 | /** |
| 1338 | * @path_blob_ptr: |
| 1339 | * |
| 1340 | * DRM blob property data for the DP MST path property. |
| 1341 | */ |
Dave Airlie | 43aba7e | 2014-06-05 14:01:31 +1000 | [diff] [blame] | 1342 | struct drm_property_blob *path_blob_ptr; |
| 1343 | |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 1344 | /** |
| 1345 | * @tile_blob_ptr: |
| 1346 | * |
| 1347 | * DRM blob property data for the tile property (used mostly by DP MST). |
| 1348 | * This is meant for screens which are driven through separate display |
| 1349 | * pipelines represented by &drm_crtc, which might not be running with |
| 1350 | * genlocked clocks. For tiled panels which are genlocked, like |
| 1351 | * dual-link LVDS or dual-link DSI, the driver should try to not expose |
| 1352 | * the tiling and virtualize both &drm_crtc and &drm_plane if needed. |
| 1353 | */ |
Dave Airlie | 6f134d7 | 2014-10-20 16:30:50 +1000 | [diff] [blame] | 1354 | struct drm_property_blob *tile_blob_ptr; |
| 1355 | |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 1356 | uint8_t polled; /* DRM_CONNECTOR_POLL_* */ |
| 1357 | |
Keith Packard | c9fb15f | 2009-05-30 20:42:28 -0700 | [diff] [blame] | 1358 | /* requested DPMS state */ |
| 1359 | int dpms; |
| 1360 | |
Daniel Vetter | 4490d4c | 2015-12-04 09:45:45 +0100 | [diff] [blame] | 1361 | const struct drm_connector_helper_funcs *helper_private; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1362 | |
Dave Airlie | d50ba25 | 2009-09-23 14:44:08 +1000 | [diff] [blame] | 1363 | /* forced on connector */ |
Chris Wilson | eaf99c7 | 2014-08-06 10:08:32 +0200 | [diff] [blame] | 1364 | struct drm_cmdline_mode cmdline_mode; |
Dave Airlie | d50ba25 | 2009-09-23 14:44:08 +1000 | [diff] [blame] | 1365 | enum drm_connector_force force; |
Thomas Wood | 4cf2b28 | 2014-06-18 17:52:33 +0100 | [diff] [blame] | 1366 | bool override_edid; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1367 | uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER]; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1368 | struct drm_encoder *encoder; /* currently active encoder */ |
Dave Airlie | 4a9a8b7 | 2011-06-14 06:13:55 +0000 | [diff] [blame] | 1369 | |
Wu Fengguang | 76adaa34 | 2011-09-05 14:23:20 +0800 | [diff] [blame] | 1370 | /* EDID bits */ |
| 1371 | uint8_t eld[MAX_ELD_BYTES]; |
| 1372 | bool dvi_dual; |
| 1373 | int max_tmds_clock; /* in MHz */ |
| 1374 | bool latency_present[2]; |
| 1375 | int video_latency[2]; /* [0]: progressive, [1]: interlaced */ |
| 1376 | int audio_latency[2]; |
Dave Airlie | 4a9a8b7 | 2011-06-14 06:13:55 +0000 | [diff] [blame] | 1377 | 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] | 1378 | unsigned bad_edid_counter; |
Thomas Wood | 30f6570 | 2014-06-18 17:52:32 +0100 | [diff] [blame] | 1379 | |
Todd Previte | 6ba2bd3 | 2015-04-21 11:09:41 -0700 | [diff] [blame] | 1380 | /* Flag for raw EDID header corruption - used in Displayport |
| 1381 | * compliance testing - * Displayport Link CTS Core 1.2 rev1.1 4.2.2.6 |
| 1382 | */ |
| 1383 | bool edid_corrupt; |
| 1384 | |
Thomas Wood | 30f6570 | 2014-06-18 17:52:32 +0100 | [diff] [blame] | 1385 | struct dentry *debugfs_entry; |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1386 | |
| 1387 | struct drm_connector_state *state; |
Dave Airlie | 40d9b04 | 2014-10-20 16:29:33 +1000 | [diff] [blame] | 1388 | |
| 1389 | /* DisplayID bits */ |
| 1390 | bool has_tile; |
| 1391 | struct drm_tile_group *tile_group; |
| 1392 | bool tile_is_single_monitor; |
| 1393 | |
| 1394 | uint8_t num_h_tile, num_v_tile; |
| 1395 | uint8_t tile_h_loc, tile_v_loc; |
| 1396 | uint16_t tile_h_size, tile_v_size; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 1397 | }; |
| 1398 | |
| 1399 | /** |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1400 | * struct drm_plane_state - mutable plane state |
Daniel Vetter | 07cc0ef | 2014-11-27 15:49:39 +0100 | [diff] [blame] | 1401 | * @plane: backpointer to the plane |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1402 | * @crtc: currently bound CRTC, NULL if disabled |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1403 | * @fb: currently bound framebuffer |
Daniel Vetter | e2330f0 | 2014-10-29 11:34:56 +0100 | [diff] [blame] | 1404 | * @fence: optional fence to wait for before scanning out @fb |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1405 | * @crtc_x: left position of visible portion of plane on crtc |
| 1406 | * @crtc_y: upper position of visible portion of plane on crtc |
| 1407 | * @crtc_w: width of visible portion of plane on crtc |
| 1408 | * @crtc_h: height of visible portion of plane on crtc |
| 1409 | * @src_x: left position of visible portion of plane within |
| 1410 | * plane (in 16.16) |
| 1411 | * @src_y: upper position of visible portion of plane within |
| 1412 | * plane (in 16.16) |
| 1413 | * @src_w: width of visible portion of plane (in 16.16) |
| 1414 | * @src_h: height of visible portion of plane (in 16.16) |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 1415 | * @rotation: rotation of the plane |
Marek Szyprowski | 44d1240d | 2016-06-13 11:11:26 +0200 | [diff] [blame] | 1416 | * @zpos: priority of the given plane on crtc (optional) |
| 1417 | * @normalized_zpos: normalized value of zpos: unique, range from 0 to N-1 |
| 1418 | * where N is the number of active planes for given crtc |
Ville Syrjälä | d7da824 | 2016-07-26 19:06:57 +0300 | [diff] [blame^] | 1419 | * @src: clipped source coordinates of the plane (in 16.16) |
| 1420 | * @dst: clipped destination coordinates of the plane |
| 1421 | * @visible: visibility of the plane |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1422 | * @state: backpointer to global drm_atomic_state |
| 1423 | */ |
| 1424 | struct drm_plane_state { |
Daniel Vetter | 07cc0ef | 2014-11-27 15:49:39 +0100 | [diff] [blame] | 1425 | struct drm_plane *plane; |
| 1426 | |
Rob Clark | 6ddd388 | 2014-11-21 15:28:31 -0500 | [diff] [blame] | 1427 | struct drm_crtc *crtc; /* do not write directly, use drm_atomic_set_crtc_for_plane() */ |
| 1428 | 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] | 1429 | struct fence *fence; |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1430 | |
| 1431 | /* Signed dest location allows it to be partially off screen */ |
| 1432 | int32_t crtc_x, crtc_y; |
| 1433 | uint32_t crtc_w, crtc_h; |
| 1434 | |
| 1435 | /* Source values are 16.16 fixed point */ |
| 1436 | uint32_t src_x, src_y; |
| 1437 | uint32_t src_h, src_w; |
| 1438 | |
Matt Roper | 1da3062 | 2015-01-21 16:35:40 -0800 | [diff] [blame] | 1439 | /* Plane rotation */ |
| 1440 | unsigned int rotation; |
| 1441 | |
Marek Szyprowski | 44d1240d | 2016-06-13 11:11:26 +0200 | [diff] [blame] | 1442 | /* Plane zpos */ |
| 1443 | unsigned int zpos; |
| 1444 | unsigned int normalized_zpos; |
| 1445 | |
Ville Syrjälä | d7da824 | 2016-07-26 19:06:57 +0300 | [diff] [blame^] | 1446 | /* Clipped coordinates */ |
| 1447 | struct drm_rect src, dst; |
| 1448 | |
| 1449 | /* |
| 1450 | * Is the plane actually visible? Can be false even |
| 1451 | * if fb!=NULL and crtc!=NULL, due to clipping. |
| 1452 | */ |
| 1453 | bool visible; |
| 1454 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1455 | struct drm_atomic_state *state; |
| 1456 | }; |
| 1457 | |
| 1458 | |
| 1459 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 1460 | * struct drm_plane_funcs - driver plane control functions |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1461 | */ |
| 1462 | struct drm_plane_funcs { |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1463 | /** |
| 1464 | * @update_plane: |
| 1465 | * |
| 1466 | * This is the legacy entry point to enable and configure the plane for |
| 1467 | * the given CRTC and framebuffer. It is never called to disable the |
| 1468 | * plane, i.e. the passed-in crtc and fb paramters are never NULL. |
| 1469 | * |
| 1470 | * The source rectangle in frame buffer memory coordinates is given by |
| 1471 | * the src_x, src_y, src_w and src_h parameters (as 16.16 fixed point |
| 1472 | * values). Devices that don't support subpixel plane coordinates can |
| 1473 | * ignore the fractional part. |
| 1474 | * |
| 1475 | * The destination rectangle in CRTC coordinates is given by the |
| 1476 | * crtc_x, crtc_y, crtc_w and crtc_h parameters (as integer values). |
| 1477 | * Devices scale the source rectangle to the destination rectangle. If |
| 1478 | * scaling is not supported, and the source rectangle size doesn't match |
| 1479 | * the destination rectangle size, the driver must return a |
| 1480 | * -<errorname>EINVAL</errorname> error. |
| 1481 | * |
| 1482 | * Drivers implementing atomic modeset should use |
| 1483 | * drm_atomic_helper_update_plane() to implement this hook. |
| 1484 | * |
| 1485 | * RETURNS: |
| 1486 | * |
| 1487 | * 0 on success or a negative error code on failure. |
| 1488 | */ |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1489 | int (*update_plane)(struct drm_plane *plane, |
| 1490 | struct drm_crtc *crtc, struct drm_framebuffer *fb, |
| 1491 | int crtc_x, int crtc_y, |
| 1492 | unsigned int crtc_w, unsigned int crtc_h, |
| 1493 | uint32_t src_x, uint32_t src_y, |
| 1494 | uint32_t src_w, uint32_t src_h); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1495 | |
| 1496 | /** |
| 1497 | * @disable_plane: |
| 1498 | * |
| 1499 | * 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] | 1500 | * 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] | 1501 | * with the frame buffer ID set to 0. Disabled planes must not be |
| 1502 | * processed by the CRTC. |
| 1503 | * |
| 1504 | * Drivers implementing atomic modeset should use |
| 1505 | * drm_atomic_helper_disable_plane() to implement this hook. |
| 1506 | * |
| 1507 | * RETURNS: |
| 1508 | * |
| 1509 | * 0 on success or a negative error code on failure. |
| 1510 | */ |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1511 | int (*disable_plane)(struct drm_plane *plane); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1512 | |
| 1513 | /** |
| 1514 | * @destroy: |
| 1515 | * |
| 1516 | * Clean up plane resources. This is only called at driver unload time |
| 1517 | * through drm_mode_config_cleanup() since a plane cannot be hotplugged |
| 1518 | * in DRM. |
| 1519 | */ |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1520 | void (*destroy)(struct drm_plane *plane); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1521 | |
| 1522 | /** |
| 1523 | * @reset: |
| 1524 | * |
| 1525 | * Reset plane hardware and software state to off. This function isn't |
| 1526 | * called by the core directly, only through drm_mode_config_reset(). |
| 1527 | * It's not a helper hook only for historical reasons. |
| 1528 | * |
| 1529 | * Atomic drivers can use drm_atomic_helper_plane_reset() to reset |
| 1530 | * atomic state using this hook. |
| 1531 | */ |
Daniel Vetter | 2a0d7cf | 2014-07-29 15:32:37 +0200 | [diff] [blame] | 1532 | void (*reset)(struct drm_plane *plane); |
Rob Clark | 4d93914 | 2012-05-17 02:23:27 -0600 | [diff] [blame] | 1533 | |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1534 | /** |
| 1535 | * @set_property: |
| 1536 | * |
| 1537 | * This is the legacy entry point to update a property attached to the |
| 1538 | * plane. |
| 1539 | * |
| 1540 | * Drivers implementing atomic modeset should use |
| 1541 | * drm_atomic_helper_plane_set_property() to implement this hook. |
| 1542 | * |
| 1543 | * This callback is optional if the driver does not support any legacy |
| 1544 | * driver-private properties. |
| 1545 | * |
| 1546 | * RETURNS: |
| 1547 | * |
| 1548 | * 0 on success or a negative error code on failure. |
| 1549 | */ |
Rob Clark | 4d93914 | 2012-05-17 02:23:27 -0600 | [diff] [blame] | 1550 | int (*set_property)(struct drm_plane *plane, |
| 1551 | struct drm_property *property, uint64_t val); |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1552 | |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1553 | /** |
| 1554 | * @atomic_duplicate_state: |
| 1555 | * |
| 1556 | * Duplicate the current atomic state for this plane and return it. |
| 1557 | * The core and helpers gurantee that any atomic state duplicated with |
| 1558 | * this hook and still owned by the caller (i.e. not transferred to the |
| 1559 | * driver by calling ->atomic_commit() from struct |
| 1560 | * &drm_mode_config_funcs) will be cleaned up by calling the |
| 1561 | * @atomic_destroy_state hook in this structure. |
| 1562 | * |
| 1563 | * Atomic drivers which don't subclass struct &drm_plane_state should use |
| 1564 | * drm_atomic_helper_plane_duplicate_state(). Drivers that subclass the |
| 1565 | * state structure to extend it with driver-private state should use |
| 1566 | * __drm_atomic_helper_plane_duplicate_state() to make sure shared state is |
| 1567 | * duplicated in a consistent fashion across drivers. |
| 1568 | * |
| 1569 | * It is an error to call this hook before plane->state has been |
| 1570 | * initialized correctly. |
| 1571 | * |
| 1572 | * NOTE: |
| 1573 | * |
| 1574 | * If the duplicate state references refcounted resources this hook must |
| 1575 | * acquire a reference for each of them. The driver must release these |
| 1576 | * references again in @atomic_destroy_state. |
| 1577 | * |
| 1578 | * RETURNS: |
| 1579 | * |
| 1580 | * Duplicated atomic state or NULL when the allocation failed. |
| 1581 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1582 | struct drm_plane_state *(*atomic_duplicate_state)(struct drm_plane *plane); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1583 | |
| 1584 | /** |
| 1585 | * @atomic_destroy_state: |
| 1586 | * |
| 1587 | * Destroy a state duplicated with @atomic_duplicate_state and release |
| 1588 | * or unreference all resources it references |
| 1589 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1590 | void (*atomic_destroy_state)(struct drm_plane *plane, |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 1591 | struct drm_plane_state *state); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1592 | |
| 1593 | /** |
| 1594 | * @atomic_set_property: |
| 1595 | * |
| 1596 | * Decode a driver-private property value and store the decoded value |
| 1597 | * into the passed-in state structure. Since the atomic core decodes all |
| 1598 | * standardized properties (even for extensions beyond the core set of |
| 1599 | * properties which might not be implemented by all drivers) this |
| 1600 | * requires drivers to subclass the state structure. |
| 1601 | * |
| 1602 | * Such driver-private properties should really only be implemented for |
| 1603 | * truly hardware/vendor specific state. Instead it is preferred to |
| 1604 | * standardize atomic extension and decode the properties used to expose |
| 1605 | * such an extension in the core. |
| 1606 | * |
| 1607 | * Do not call this function directly, use |
| 1608 | * drm_atomic_plane_set_property() instead. |
| 1609 | * |
| 1610 | * This callback is optional if the driver does not support any |
| 1611 | * driver-private atomic properties. |
| 1612 | * |
| 1613 | * NOTE: |
| 1614 | * |
| 1615 | * This function is called in the state assembly phase of atomic |
| 1616 | * modesets, which can be aborted for any reason (including on |
| 1617 | * userspace's request to just check whether a configuration would be |
| 1618 | * possible). Drivers MUST NOT touch any persistent state (hardware or |
| 1619 | * software) or data structures except the passed in @state parameter. |
| 1620 | * |
| 1621 | * Also since userspace controls in which order properties are set this |
| 1622 | * function must not do any input validation (since the state update is |
| 1623 | * incomplete and hence likely inconsistent). Instead any such input |
| 1624 | * validation must be done in the various atomic_check callbacks. |
| 1625 | * |
| 1626 | * RETURNS: |
| 1627 | * |
| 1628 | * 0 if the property has been found, -EINVAL if the property isn't |
| 1629 | * implemented by the driver (which shouldn't ever happen, the core only |
| 1630 | * asks for properties attached to this plane). No other validation is |
| 1631 | * allowed by the driver. The core already checks that the property |
| 1632 | * value is within the range (integer, valid enum value, ...) the driver |
| 1633 | * set when registering the property. |
| 1634 | */ |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1635 | int (*atomic_set_property)(struct drm_plane *plane, |
| 1636 | struct drm_plane_state *state, |
| 1637 | struct drm_property *property, |
| 1638 | uint64_t val); |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1639 | |
| 1640 | /** |
| 1641 | * @atomic_get_property: |
| 1642 | * |
| 1643 | * Reads out the decoded driver-private property. This is used to |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 1644 | * implement the GETPLANE IOCTL. |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1645 | * |
| 1646 | * Do not call this function directly, use |
| 1647 | * drm_atomic_plane_get_property() instead. |
| 1648 | * |
| 1649 | * This callback is optional if the driver does not support any |
| 1650 | * driver-private atomic properties. |
| 1651 | * |
| 1652 | * RETURNS: |
| 1653 | * |
| 1654 | * 0 on success, -EINVAL if the property isn't implemented by the |
| 1655 | * driver (which should never happen, the core only asks for |
| 1656 | * properties attached to this plane). |
| 1657 | */ |
Rob Clark | ac9c925 | 2014-12-18 16:01:47 -0500 | [diff] [blame] | 1658 | int (*atomic_get_property)(struct drm_plane *plane, |
| 1659 | const struct drm_plane_state *state, |
| 1660 | struct drm_property *property, |
| 1661 | uint64_t *val); |
Benjamin Gaignard | 79190ea | 2016-06-21 16:37:09 +0200 | [diff] [blame] | 1662 | /** |
| 1663 | * @late_register: |
| 1664 | * |
| 1665 | * This optional hook can be used to register additional userspace |
| 1666 | * interfaces attached to the plane like debugfs interfaces. |
| 1667 | * It is called late in the driver load sequence from drm_dev_register(). |
| 1668 | * Everything added from this callback should be unregistered in |
| 1669 | * the early_unregister callback. |
| 1670 | * |
| 1671 | * Returns: |
| 1672 | * |
| 1673 | * 0 on success, or a negative error code on failure. |
| 1674 | */ |
| 1675 | int (*late_register)(struct drm_plane *plane); |
| 1676 | |
| 1677 | /** |
| 1678 | * @early_unregister: |
| 1679 | * |
| 1680 | * This optional hook should be used to unregister the additional |
| 1681 | * userspace interfaces attached to the plane from |
| 1682 | * late_unregister(). It is called from drm_dev_unregister(), |
| 1683 | * early in the driver unload sequence to disable userspace access |
| 1684 | * before data structures are torndown. |
| 1685 | */ |
| 1686 | void (*early_unregister)(struct drm_plane *plane); |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1687 | }; |
| 1688 | |
Matt Roper | e27dde3 | 2014-04-01 15:22:30 -0700 | [diff] [blame] | 1689 | enum drm_plane_type { |
| 1690 | DRM_PLANE_TYPE_OVERLAY, |
| 1691 | DRM_PLANE_TYPE_PRIMARY, |
| 1692 | DRM_PLANE_TYPE_CURSOR, |
| 1693 | }; |
| 1694 | |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1695 | |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1696 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 1697 | * struct drm_plane - central DRM plane control structure |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1698 | * @dev: DRM device this plane belongs to |
| 1699 | * @head: for list management |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 1700 | * @name: human readable name, can be overwritten by the driver |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1701 | * @base: base mode object |
| 1702 | * @possible_crtcs: pipes this plane can be bound to |
| 1703 | * @format_types: array of formats supported by this plane |
| 1704 | * @format_count: number of formats supported |
Laurent Pinchart | 7eb5f30 | 2015-03-09 10:41:07 +0200 | [diff] [blame] | 1705 | * @format_default: driver hasn't supplied supported formats for the plane |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1706 | * @crtc: currently bound CRTC |
| 1707 | * @fb: currently bound fb |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 1708 | * @old_fb: Temporary tracking of the old fb while a modeset is ongoing. Used by |
| 1709 | * drm_mode_set_config_internal() to implement correct refcounting. |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1710 | * @funcs: helper functions |
Rob Clark | 4d93914 | 2012-05-17 02:23:27 -0600 | [diff] [blame] | 1711 | * @properties: property tracking for this plane |
Matt Roper | e27dde3 | 2014-04-01 15:22:30 -0700 | [diff] [blame] | 1712 | * @type: type of plane (overlay, primary, cursor) |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1713 | * @state: current atomic state for this plane |
Marek Szyprowski | 44d1240d | 2016-06-13 11:11:26 +0200 | [diff] [blame] | 1714 | * @zpos_property: zpos property for this plane |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 1715 | * @helper_private: mid-layer private data |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1716 | */ |
| 1717 | struct drm_plane { |
| 1718 | struct drm_device *dev; |
| 1719 | struct list_head head; |
| 1720 | |
Ville Syrjälä | 9f4c97a | 2015-12-08 18:41:54 +0200 | [diff] [blame] | 1721 | char *name; |
| 1722 | |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 1723 | /** |
| 1724 | * @mutex: |
| 1725 | * |
| 1726 | * Protects modeset plane state, together with the mutex of &drm_crtc |
| 1727 | * this plane is linked to (when active, getting actived or getting |
| 1728 | * disabled). |
| 1729 | */ |
Daniel Vetter | 4d02e2d | 2014-11-11 10:12:00 +0100 | [diff] [blame] | 1730 | struct drm_modeset_lock mutex; |
| 1731 | |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1732 | struct drm_mode_object base; |
| 1733 | |
| 1734 | uint32_t possible_crtcs; |
| 1735 | uint32_t *format_types; |
Thierry Reding | 45e3743 | 2015-08-12 16:54:28 +0200 | [diff] [blame] | 1736 | unsigned int format_count; |
Laurent Pinchart | 7eb5f30 | 2015-03-09 10:41:07 +0200 | [diff] [blame] | 1737 | bool format_default; |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1738 | |
| 1739 | struct drm_crtc *crtc; |
| 1740 | struct drm_framebuffer *fb; |
| 1741 | |
Daniel Vetter | 3d30a59 | 2014-07-27 13:42:42 +0200 | [diff] [blame] | 1742 | struct drm_framebuffer *old_fb; |
| 1743 | |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1744 | const struct drm_plane_funcs *funcs; |
Rob Clark | 4d93914 | 2012-05-17 02:23:27 -0600 | [diff] [blame] | 1745 | |
| 1746 | struct drm_object_properties properties; |
Matt Roper | e27dde3 | 2014-04-01 15:22:30 -0700 | [diff] [blame] | 1747 | |
| 1748 | enum drm_plane_type type; |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1749 | |
Daniel Vetter | 9609408 | 2016-07-15 21:47:59 +0200 | [diff] [blame] | 1750 | /** |
| 1751 | * @index: Position inside the mode_config.list, can be used as an array |
| 1752 | * index. It is invariant over the lifetime of the plane. |
| 1753 | */ |
Chris Wilson | 490d3d1 | 2016-05-27 20:05:00 +0100 | [diff] [blame] | 1754 | unsigned index; |
| 1755 | |
Daniel Vetter | 4490d4c | 2015-12-04 09:45:45 +0100 | [diff] [blame] | 1756 | const struct drm_plane_helper_funcs *helper_private; |
Daniel Vetter | c2fcd27 | 2014-11-05 00:14:14 +0100 | [diff] [blame] | 1757 | |
Daniel Vetter | 144ecb9 | 2014-10-27 20:28:44 +0100 | [diff] [blame] | 1758 | struct drm_plane_state *state; |
Marek Szyprowski | 44d1240d | 2016-06-13 11:11:26 +0200 | [diff] [blame] | 1759 | |
| 1760 | struct drm_property *zpos_property; |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 1761 | }; |
| 1762 | |
| 1763 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 1764 | * struct drm_bridge_funcs - drm_bridge control functions |
Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 1765 | * @attach: Called during drm_bridge_attach |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1766 | */ |
| 1767 | struct drm_bridge_funcs { |
Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 1768 | int (*attach)(struct drm_bridge *bridge); |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1769 | |
| 1770 | /** |
| 1771 | * @mode_fixup: |
| 1772 | * |
| 1773 | * This callback is used to validate and adjust a mode. The paramater |
| 1774 | * mode is the display mode that should be fed to the next element in |
| 1775 | * the display chain, either the final &drm_connector or the next |
| 1776 | * &drm_bridge. The parameter adjusted_mode is the input mode the bridge |
| 1777 | * requires. It can be modified by this callback and does not need to |
| 1778 | * match mode. |
| 1779 | * |
| 1780 | * This is the only hook that allows a bridge to reject a modeset. If |
| 1781 | * this function passes all other callbacks must succeed for this |
| 1782 | * configuration. |
| 1783 | * |
| 1784 | * NOTE: |
| 1785 | * |
| 1786 | * This function is called in the check phase of atomic modesets, which |
| 1787 | * can be aborted for any reason (including on userspace's request to |
| 1788 | * just check whether a configuration would be possible). Drivers MUST |
| 1789 | * NOT touch any persistent state (hardware or software) or data |
Daniel Vetter | 8854863 | 2015-12-04 09:45:48 +0100 | [diff] [blame] | 1790 | * structures except the passed in @state parameter. |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1791 | * |
| 1792 | * RETURNS: |
| 1793 | * |
| 1794 | * True if an acceptable configuration is possible, false if the modeset |
| 1795 | * operation should be rejected. |
| 1796 | */ |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1797 | bool (*mode_fixup)(struct drm_bridge *bridge, |
| 1798 | const struct drm_display_mode *mode, |
| 1799 | struct drm_display_mode *adjusted_mode); |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1800 | /** |
| 1801 | * @disable: |
| 1802 | * |
| 1803 | * This callback should disable the bridge. It is called right before |
| 1804 | * the preceding element in the display pipe is disabled. If the |
| 1805 | * preceding element is a bridge this means it's called before that |
| 1806 | * bridge's ->disable() function. If the preceding element is a |
| 1807 | * &drm_encoder it's called right before the encoder's ->disable(), |
| 1808 | * ->prepare() or ->dpms() hook from struct &drm_encoder_helper_funcs. |
| 1809 | * |
| 1810 | * The bridge can assume that the display pipe (i.e. clocks and timing |
| 1811 | * signals) feeding it is still running when this callback is called. |
Laurent Pinchart | c8a3b2a | 2016-02-26 11:51:06 +0200 | [diff] [blame] | 1812 | * |
| 1813 | * The disable callback is optional. |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1814 | */ |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1815 | void (*disable)(struct drm_bridge *bridge); |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1816 | |
| 1817 | /** |
| 1818 | * @post_disable: |
| 1819 | * |
| 1820 | * This callback should disable the bridge. It is called right after |
| 1821 | * the preceding element in the display pipe is disabled. If the |
| 1822 | * preceding element is a bridge this means it's called after that |
| 1823 | * bridge's ->post_disable() function. If the preceding element is a |
| 1824 | * &drm_encoder it's called right after the encoder's ->disable(), |
| 1825 | * ->prepare() or ->dpms() hook from struct &drm_encoder_helper_funcs. |
| 1826 | * |
| 1827 | * The bridge must assume that the display pipe (i.e. clocks and timing |
| 1828 | * singals) feeding it is no longer running when this callback is |
| 1829 | * called. |
Laurent Pinchart | c8a3b2a | 2016-02-26 11:51:06 +0200 | [diff] [blame] | 1830 | * |
| 1831 | * The post_disable callback is optional. |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1832 | */ |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1833 | void (*post_disable)(struct drm_bridge *bridge); |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1834 | |
| 1835 | /** |
| 1836 | * @mode_set: |
| 1837 | * |
| 1838 | * This callback should set the given mode on the bridge. It is called |
| 1839 | * after the ->mode_set() callback for the preceding element in the |
| 1840 | * display pipeline has been called already. The display pipe (i.e. |
| 1841 | * clocks and timing signals) is off when this function is called. |
| 1842 | */ |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1843 | void (*mode_set)(struct drm_bridge *bridge, |
| 1844 | struct drm_display_mode *mode, |
| 1845 | struct drm_display_mode *adjusted_mode); |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1846 | /** |
| 1847 | * @pre_enable: |
| 1848 | * |
| 1849 | * This callback should enable the bridge. It is called right before |
| 1850 | * the preceding element in the display pipe is enabled. If the |
| 1851 | * preceding element is a bridge this means it's called before that |
| 1852 | * bridge's ->pre_enable() function. If the preceding element is a |
| 1853 | * &drm_encoder it's called right before the encoder's ->enable(), |
| 1854 | * ->commit() or ->dpms() hook from struct &drm_encoder_helper_funcs. |
| 1855 | * |
| 1856 | * The display pipe (i.e. clocks and timing signals) feeding this bridge |
| 1857 | * will not yet be running when this callback is called. The bridge must |
| 1858 | * not enable the display link feeding the next bridge in the chain (if |
| 1859 | * there is one) when this callback is called. |
Laurent Pinchart | c8a3b2a | 2016-02-26 11:51:06 +0200 | [diff] [blame] | 1860 | * |
| 1861 | * The pre_enable callback is optional. |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1862 | */ |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1863 | void (*pre_enable)(struct drm_bridge *bridge); |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1864 | |
| 1865 | /** |
| 1866 | * @enable: |
| 1867 | * |
| 1868 | * This callback should enable the bridge. It is called right after |
| 1869 | * the preceding element in the display pipe is enabled. If the |
| 1870 | * preceding element is a bridge this means it's called after that |
| 1871 | * bridge's ->enable() function. If the preceding element is a |
| 1872 | * &drm_encoder it's called right after the encoder's ->enable(), |
| 1873 | * ->commit() or ->dpms() hook from struct &drm_encoder_helper_funcs. |
| 1874 | * |
| 1875 | * The bridge can assume that the display pipe (i.e. clocks and timing |
| 1876 | * signals) feeding it is running when this callback is called. This |
| 1877 | * callback must enable the display link feeding the next bridge in the |
| 1878 | * chain if there is one. |
Laurent Pinchart | c8a3b2a | 2016-02-26 11:51:06 +0200 | [diff] [blame] | 1879 | * |
| 1880 | * The enable callback is optional. |
Daniel Vetter | da024fe | 2015-12-04 09:45:47 +0100 | [diff] [blame] | 1881 | */ |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1882 | void (*enable)(struct drm_bridge *bridge); |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1883 | }; |
| 1884 | |
| 1885 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 1886 | * struct drm_bridge - central DRM bridge control structure |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1887 | * @dev: DRM device this bridge belongs to |
Archit Taneja | 862e686 | 2015-05-21 11:03:16 +0530 | [diff] [blame] | 1888 | * @encoder: encoder to which this bridge is connected |
| 1889 | * @next: the next bridge in the encoder chain |
Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 1890 | * @of_node: device node pointer to the bridge |
| 1891 | * @list: to keep track of all added bridges |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1892 | * @funcs: control functions |
| 1893 | * @driver_private: pointer to the bridge driver's internal context |
| 1894 | */ |
| 1895 | struct drm_bridge { |
| 1896 | struct drm_device *dev; |
Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 1897 | struct drm_encoder *encoder; |
Archit Taneja | 862e686 | 2015-05-21 11:03:16 +0530 | [diff] [blame] | 1898 | struct drm_bridge *next; |
Ajay Kumar | 3d3f8b1 | 2015-01-20 22:08:44 +0530 | [diff] [blame] | 1899 | #ifdef CONFIG_OF |
| 1900 | struct device_node *of_node; |
| 1901 | #endif |
| 1902 | struct list_head list; |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 1903 | |
| 1904 | const struct drm_bridge_funcs *funcs; |
| 1905 | void *driver_private; |
| 1906 | }; |
| 1907 | |
Daniel Vetter | 3b24f7d | 2016-06-08 14:19:00 +0200 | [diff] [blame] | 1908 | /** |
| 1909 | * struct drm_crtc_commit - track modeset commits on a CRTC |
| 1910 | * |
| 1911 | * This structure is used to track pending modeset changes and atomic commit on |
| 1912 | * a per-CRTC basis. Since updating the list should never block this structure |
| 1913 | * is reference counted to allow waiters to safely wait on an event to complete, |
| 1914 | * without holding any locks. |
| 1915 | * |
| 1916 | * It has 3 different events in total to allow a fine-grained synchronization |
| 1917 | * between outstanding updates:: |
| 1918 | * |
| 1919 | * atomic commit thread hardware |
| 1920 | * |
| 1921 | * write new state into hardware ----> ... |
| 1922 | * signal hw_done |
| 1923 | * switch to new state on next |
| 1924 | * ... v/hblank |
| 1925 | * |
| 1926 | * wait for buffers to show up ... |
| 1927 | * |
| 1928 | * ... send completion irq |
| 1929 | * irq handler signals flip_done |
| 1930 | * cleanup old buffers |
| 1931 | * |
| 1932 | * signal cleanup_done |
| 1933 | * |
| 1934 | * wait for flip_done <---- |
| 1935 | * clean up atomic state |
| 1936 | * |
| 1937 | * The important bit to know is that cleanup_done is the terminal event, but the |
| 1938 | * ordering between flip_done and hw_done is entirely up to the specific driver |
| 1939 | * and modeset state change. |
| 1940 | * |
| 1941 | * For an implementation of how to use this look at |
| 1942 | * drm_atomic_helper_setup_commit() from the atomic helper library. |
| 1943 | */ |
| 1944 | struct drm_crtc_commit { |
| 1945 | /** |
| 1946 | * @crtc: |
| 1947 | * |
| 1948 | * DRM CRTC for this commit. |
| 1949 | */ |
| 1950 | struct drm_crtc *crtc; |
| 1951 | |
| 1952 | /** |
| 1953 | * @ref: |
| 1954 | * |
| 1955 | * Reference count for this structure. Needed to allow blocking on |
| 1956 | * completions without the risk of the completion disappearing |
| 1957 | * meanwhile. |
| 1958 | */ |
| 1959 | struct kref ref; |
| 1960 | |
| 1961 | /** |
| 1962 | * @flip_done: |
| 1963 | * |
| 1964 | * Will be signaled when the hardware has flipped to the new set of |
| 1965 | * buffers. Signals at the same time as when the drm event for this |
| 1966 | * commit is sent to userspace, or when an out-fence is singalled. Note |
| 1967 | * that for most hardware, in most cases this happens after @hw_done is |
| 1968 | * signalled. |
| 1969 | */ |
| 1970 | struct completion flip_done; |
| 1971 | |
| 1972 | /** |
| 1973 | * @hw_done: |
| 1974 | * |
| 1975 | * Will be signalled when all hw register changes for this commit have |
| 1976 | * been written out. Especially when disabling a pipe this can be much |
| 1977 | * later than than @flip_done, since that can signal already when the |
| 1978 | * screen goes black, whereas to fully shut down a pipe more register |
| 1979 | * I/O is required. |
| 1980 | * |
| 1981 | * Note that this does not need to include separately reference-counted |
| 1982 | * resources like backing storage buffer pinning, or runtime pm |
| 1983 | * management. |
| 1984 | */ |
| 1985 | struct completion hw_done; |
| 1986 | |
| 1987 | /** |
| 1988 | * @cleanup_done: |
| 1989 | * |
| 1990 | * Will be signalled after old buffers have been cleaned up by calling |
| 1991 | * drm_atomic_helper_cleanup_planes(). Since this can only happen after |
| 1992 | * a vblank wait completed it might be a bit later. This completion is |
| 1993 | * useful to throttle updates and avoid hardware updates getting ahead |
| 1994 | * of the buffer cleanup too much. |
| 1995 | */ |
| 1996 | struct completion cleanup_done; |
| 1997 | |
| 1998 | /** |
| 1999 | * @commit_entry: |
| 2000 | * |
| 2001 | * Entry on the per-CRTC commit_list. Protected by crtc->commit_lock. |
| 2002 | */ |
| 2003 | struct list_head commit_entry; |
| 2004 | |
| 2005 | /** |
| 2006 | * @event: |
| 2007 | * |
| 2008 | * &drm_pending_vblank_event pointer to clean up private events. |
| 2009 | */ |
| 2010 | struct drm_pending_vblank_event *event; |
| 2011 | }; |
| 2012 | |
Daniel Vetter | b8b5342 | 2016-06-02 00:06:33 +0200 | [diff] [blame] | 2013 | struct __drm_planes_state { |
| 2014 | struct drm_plane *ptr; |
| 2015 | struct drm_plane_state *state; |
| 2016 | }; |
| 2017 | |
Daniel Vetter | 5d943aa6 | 2016-06-02 00:06:34 +0200 | [diff] [blame] | 2018 | struct __drm_crtcs_state { |
| 2019 | struct drm_crtc *ptr; |
| 2020 | struct drm_crtc_state *state; |
Daniel Vetter | 3b24f7d | 2016-06-08 14:19:00 +0200 | [diff] [blame] | 2021 | struct drm_crtc_commit *commit; |
Daniel Vetter | 5d943aa6 | 2016-06-02 00:06:34 +0200 | [diff] [blame] | 2022 | }; |
| 2023 | |
Daniel Vetter | 63e83c1 | 2016-06-02 00:06:32 +0200 | [diff] [blame] | 2024 | struct __drm_connnectors_state { |
| 2025 | struct drm_connector *ptr; |
| 2026 | struct drm_connector_state *state; |
| 2027 | }; |
| 2028 | |
Sean Paul | 3b336ec | 2013-08-14 16:47:37 -0400 | [diff] [blame] | 2029 | /** |
Rob Clark | 08855fa | 2015-03-11 10:23:09 -0400 | [diff] [blame] | 2030 | * struct drm_atomic_state - the global state object for atomic updates |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 2031 | * @dev: parent DRM device |
Rob Clark | d34f20d | 2014-12-18 16:01:56 -0500 | [diff] [blame] | 2032 | * @allow_modeset: allow full modeset |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 2033 | * @legacy_cursor_update: hint to enforce legacy cursor IOCTL semantics |
Maarten Lankhorst | 40616a2 | 2016-03-03 10:17:39 +0100 | [diff] [blame] | 2034 | * @legacy_set_config: Disable conflicting encoders instead of failing with -EINVAL. |
Daniel Vetter | b8b5342 | 2016-06-02 00:06:33 +0200 | [diff] [blame] | 2035 | * @planes: pointer to array of structures with per-plane data |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 2036 | * @crtcs: pointer to array of CRTC pointers |
Daniel Vetter | f52b69f1 | 2014-11-19 18:38:08 +0100 | [diff] [blame] | 2037 | * @num_connector: size of the @connectors and @connector_states arrays |
Daniel Vetter | 63e83c1 | 2016-06-02 00:06:32 +0200 | [diff] [blame] | 2038 | * @connectors: pointer to array of structures with per-connector data |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 2039 | * @acquire_ctx: acquire context for this atomic modeset state update |
| 2040 | */ |
| 2041 | struct drm_atomic_state { |
| 2042 | struct drm_device *dev; |
Rob Clark | d34f20d | 2014-12-18 16:01:56 -0500 | [diff] [blame] | 2043 | bool allow_modeset : 1; |
Daniel Vetter | f02ad90 | 2015-01-22 16:36:23 +0100 | [diff] [blame] | 2044 | bool legacy_cursor_update : 1; |
Maarten Lankhorst | 40616a2 | 2016-03-03 10:17:39 +0100 | [diff] [blame] | 2045 | bool legacy_set_config : 1; |
Daniel Vetter | b8b5342 | 2016-06-02 00:06:33 +0200 | [diff] [blame] | 2046 | struct __drm_planes_state *planes; |
Daniel Vetter | 5d943aa6 | 2016-06-02 00:06:34 +0200 | [diff] [blame] | 2047 | struct __drm_crtcs_state *crtcs; |
Daniel Vetter | f52b69f1 | 2014-11-19 18:38:08 +0100 | [diff] [blame] | 2048 | int num_connector; |
Daniel Vetter | 63e83c1 | 2016-06-02 00:06:32 +0200 | [diff] [blame] | 2049 | struct __drm_connnectors_state *connectors; |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 2050 | |
| 2051 | struct drm_modeset_acquire_ctx *acquire_ctx; |
Daniel Vetter | 3b24f7d | 2016-06-08 14:19:00 +0200 | [diff] [blame] | 2052 | |
| 2053 | /** |
| 2054 | * @commit_work: |
| 2055 | * |
| 2056 | * Work item which can be used by the driver or helpers to execute the |
| 2057 | * commit without blocking. |
| 2058 | */ |
| 2059 | struct work_struct commit_work; |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 2060 | }; |
| 2061 | |
| 2062 | |
| 2063 | /** |
Daniel Vetter | 3bf0401 | 2014-10-27 16:54:27 +0100 | [diff] [blame] | 2064 | * struct drm_mode_set - new values for a CRTC config change |
Jesse Barnes | ef27351 | 2011-11-07 12:03:19 -0800 | [diff] [blame] | 2065 | * @fb: framebuffer to use for new config |
| 2066 | * @crtc: CRTC whose configuration we're about to change |
| 2067 | * @mode: mode timings to use |
| 2068 | * @x: position of this CRTC relative to @fb |
| 2069 | * @y: position of this CRTC relative to @fb |
| 2070 | * @connectors: array of connectors to drive with this CRTC if possible |
| 2071 | * @num_connectors: size of @connectors array |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2072 | * |
| 2073 | * Represents a single crtc the connectors that it drives with what mode |
| 2074 | * and from which framebuffer it scans out from. |
| 2075 | * |
| 2076 | * This is used to set modes. |
| 2077 | */ |
| 2078 | struct drm_mode_set { |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2079 | struct drm_framebuffer *fb; |
| 2080 | struct drm_crtc *crtc; |
| 2081 | struct drm_display_mode *mode; |
| 2082 | |
| 2083 | uint32_t x; |
| 2084 | uint32_t y; |
| 2085 | |
| 2086 | struct drm_connector **connectors; |
| 2087 | size_t num_connectors; |
| 2088 | }; |
| 2089 | |
| 2090 | /** |
Jesse Barnes | 550cebc | 2011-11-07 12:03:20 -0800 | [diff] [blame] | 2091 | * struct drm_mode_config_funcs - basic driver provided mode setting functions |
Jesse Barnes | 550cebc | 2011-11-07 12:03:20 -0800 | [diff] [blame] | 2092 | * |
| 2093 | * Some global (i.e. not per-CRTC, connector, etc) mode setting functions that |
| 2094 | * involve drivers. |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2095 | */ |
| 2096 | struct drm_mode_config_funcs { |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 2097 | /** |
| 2098 | * @fb_create: |
| 2099 | * |
| 2100 | * Create a new framebuffer object. The core does basic checks on the |
| 2101 | * requested metadata, but most of that is left to the driver. See |
| 2102 | * struct &drm_mode_fb_cmd2 for details. |
| 2103 | * |
Daniel Vetter | d55f532 | 2015-12-08 09:49:19 +0100 | [diff] [blame] | 2104 | * If the parameters are deemed valid and the backing storage objects in |
| 2105 | * the underlying memory manager all exist, then the driver allocates |
| 2106 | * a new &drm_framebuffer structure, subclassed to contain |
| 2107 | * driver-specific information (like the internal native buffer object |
| 2108 | * references). It also needs to fill out all relevant metadata, which |
| 2109 | * should be done by calling drm_helper_mode_fill_fb_struct(). |
| 2110 | * |
| 2111 | * The initialization is finalized by calling drm_framebuffer_init(), |
| 2112 | * which registers the framebuffer and makes it accessible to other |
| 2113 | * threads. |
| 2114 | * |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 2115 | * RETURNS: |
| 2116 | * |
| 2117 | * A new framebuffer with an initial reference count of 1 or a negative |
| 2118 | * error code encoded with ERR_PTR(). |
| 2119 | */ |
Jesse Barnes | 550cebc | 2011-11-07 12:03:20 -0800 | [diff] [blame] | 2120 | struct drm_framebuffer *(*fb_create)(struct drm_device *dev, |
| 2121 | struct drm_file *file_priv, |
Ville Syrjälä | 1eb8345 | 2015-11-11 19:11:29 +0200 | [diff] [blame] | 2122 | const struct drm_mode_fb_cmd2 *mode_cmd); |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 2123 | |
| 2124 | /** |
| 2125 | * @output_poll_changed: |
| 2126 | * |
| 2127 | * Callback used by helpers to inform the driver of output configuration |
| 2128 | * changes. |
| 2129 | * |
| 2130 | * Drivers implementing fbdev emulation with the helpers can call |
| 2131 | * drm_fb_helper_hotplug_changed from this hook to inform the fbdev |
| 2132 | * helper of output changes. |
| 2133 | * |
| 2134 | * FIXME: |
| 2135 | * |
| 2136 | * Except that there's no vtable for device-level helper callbacks |
| 2137 | * there's no reason this is a core function. |
| 2138 | */ |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 2139 | void (*output_poll_changed)(struct drm_device *dev); |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 2140 | |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 2141 | /** |
| 2142 | * @atomic_check: |
| 2143 | * |
| 2144 | * This is the only hook to validate an atomic modeset update. This |
| 2145 | * function must reject any modeset and state changes which the hardware |
| 2146 | * or driver doesn't support. This includes but is of course not limited |
| 2147 | * to: |
| 2148 | * |
| 2149 | * - Checking that the modes, framebuffers, scaling and placement |
| 2150 | * requirements and so on are within the limits of the hardware. |
| 2151 | * |
| 2152 | * - Checking that any hidden shared resources are not oversubscribed. |
| 2153 | * This can be shared PLLs, shared lanes, overall memory bandwidth, |
| 2154 | * display fifo space (where shared between planes or maybe even |
| 2155 | * CRTCs). |
| 2156 | * |
| 2157 | * - Checking that virtualized resources exported to userspace are not |
| 2158 | * oversubscribed. For various reasons it can make sense to expose |
| 2159 | * more planes, crtcs or encoders than which are physically there. One |
| 2160 | * example is dual-pipe operations (which generally should be hidden |
| 2161 | * from userspace if when lockstepped in hardware, exposed otherwise), |
| 2162 | * where a plane might need 1 hardware plane (if it's just on one |
| 2163 | * pipe), 2 hardware planes (when it spans both pipes) or maybe even |
| 2164 | * shared a hardware plane with a 2nd plane (if there's a compatible |
| 2165 | * plane requested on the area handled by the other pipe). |
| 2166 | * |
| 2167 | * - Check that any transitional state is possible and that if |
| 2168 | * requested, the update can indeed be done in the vblank period |
| 2169 | * without temporarily disabling some functions. |
| 2170 | * |
| 2171 | * - Check any other constraints the driver or hardware might have. |
| 2172 | * |
| 2173 | * - This callback also needs to correctly fill out the &drm_crtc_state |
| 2174 | * in this update to make sure that drm_atomic_crtc_needs_modeset() |
| 2175 | * reflects the nature of the possible update and returns true if and |
| 2176 | * only if the update cannot be applied without tearing within one |
| 2177 | * vblank on that CRTC. The core uses that information to reject |
| 2178 | * updates which require a full modeset (i.e. blanking the screen, or |
| 2179 | * at least pausing updates for a substantial amount of time) if |
| 2180 | * userspace has disallowed that in its request. |
| 2181 | * |
| 2182 | * - The driver also does not need to repeat basic input validation |
| 2183 | * like done for the corresponding legacy entry points. The core does |
| 2184 | * that before calling this hook. |
| 2185 | * |
| 2186 | * See the documentation of @atomic_commit for an exhaustive list of |
| 2187 | * error conditions which don't have to be checked at the |
| 2188 | * ->atomic_check() stage? |
| 2189 | * |
| 2190 | * See the documentation for struct &drm_atomic_state for how exactly |
| 2191 | * an atomic modeset update is described. |
| 2192 | * |
| 2193 | * Drivers using the atomic helpers can implement this hook using |
| 2194 | * drm_atomic_helper_check(), or one of the exported sub-functions of |
| 2195 | * it. |
| 2196 | * |
| 2197 | * RETURNS: |
| 2198 | * |
| 2199 | * 0 on success or one of the below negative error codes: |
| 2200 | * |
| 2201 | * - -EINVAL, if any of the above constraints are violated. |
| 2202 | * |
| 2203 | * - -EDEADLK, when returned from an attempt to acquire an additional |
| 2204 | * &drm_modeset_lock through drm_modeset_lock(). |
| 2205 | * |
| 2206 | * - -ENOMEM, if allocating additional state sub-structures failed due |
| 2207 | * to lack of memory. |
| 2208 | * |
| 2209 | * - -EINTR, -EAGAIN or -ERESTARTSYS, if the IOCTL should be restarted. |
| 2210 | * This can either be due to a pending signal, or because the driver |
| 2211 | * needs to completely bail out to recover from an exceptional |
| 2212 | * situation like a GPU hang. From a userspace point all errors are |
| 2213 | * treated equally. |
| 2214 | */ |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 2215 | int (*atomic_check)(struct drm_device *dev, |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 2216 | struct drm_atomic_state *state); |
| 2217 | |
| 2218 | /** |
| 2219 | * @atomic_commit: |
| 2220 | * |
| 2221 | * This is the only hook to commit an atomic modeset update. The core |
| 2222 | * guarantees that @atomic_check has been called successfully before |
| 2223 | * calling this function, and that nothing has been changed in the |
| 2224 | * interim. |
| 2225 | * |
| 2226 | * See the documentation for struct &drm_atomic_state for how exactly |
| 2227 | * an atomic modeset update is described. |
| 2228 | * |
| 2229 | * Drivers using the atomic helpers can implement this hook using |
| 2230 | * drm_atomic_helper_commit(), or one of the exported sub-functions of |
| 2231 | * it. |
| 2232 | * |
Maarten Lankhorst | 286dbb8 | 2016-04-26 16:11:34 +0200 | [diff] [blame] | 2233 | * Nonblocking commits (as indicated with the nonblock parameter) must |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 2234 | * do any preparatory work which might result in an unsuccessful commit |
| 2235 | * in the context of this callback. The only exceptions are hardware |
| 2236 | * errors resulting in -EIO. But even in that case the driver must |
| 2237 | * ensure that the display pipe is at least running, to avoid |
| 2238 | * compositors crashing when pageflips don't work. Anything else, |
| 2239 | * specifically committing the update to the hardware, should be done |
| 2240 | * without blocking the caller. For updates which do not require a |
| 2241 | * modeset this must be guaranteed. |
| 2242 | * |
| 2243 | * The driver must wait for any pending rendering to the new |
| 2244 | * framebuffers to complete before executing the flip. It should also |
| 2245 | * wait for any pending rendering from other drivers if the underlying |
Maarten Lankhorst | 286dbb8 | 2016-04-26 16:11:34 +0200 | [diff] [blame] | 2246 | * buffer is a shared dma-buf. Nonblocking commits must not wait for |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 2247 | * rendering in the context of this callback. |
| 2248 | * |
| 2249 | * An application can request to be notified when the atomic commit has |
| 2250 | * completed. These events are per-CRTC and can be distinguished by the |
| 2251 | * CRTC index supplied in &drm_event to userspace. |
| 2252 | * |
| 2253 | * The drm core will supply a struct &drm_event in the event |
| 2254 | * member of each CRTC's &drm_crtc_state structure. This can be handled by the |
| 2255 | * drm_crtc_send_vblank_event() function, which the driver should call on |
| 2256 | * the provided event upon completion of the atomic commit. Note that if |
| 2257 | * the driver supports vblank signalling and timestamping the vblank |
| 2258 | * counters and timestamps must agree with the ones returned from page |
| 2259 | * flip events. With the current vblank helper infrastructure this can |
| 2260 | * be achieved by holding a vblank reference while the page flip is |
| 2261 | * pending, acquired through drm_crtc_vblank_get() and released with |
| 2262 | * drm_crtc_vblank_put(). Drivers are free to implement their own vblank |
| 2263 | * counter and timestamp tracking though, e.g. if they have accurate |
| 2264 | * timestamp registers in hardware. |
| 2265 | * |
| 2266 | * NOTE: |
| 2267 | * |
| 2268 | * Drivers are not allowed to shut down any display pipe successfully |
| 2269 | * enabled through an atomic commit on their own. Doing so can result in |
| 2270 | * compositors crashing if a page flip is suddenly rejected because the |
| 2271 | * pipe is off. |
| 2272 | * |
| 2273 | * RETURNS: |
| 2274 | * |
| 2275 | * 0 on success or one of the below negative error codes: |
| 2276 | * |
Maarten Lankhorst | 286dbb8 | 2016-04-26 16:11:34 +0200 | [diff] [blame] | 2277 | * - -EBUSY, if a nonblocking updated is requested and there is |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 2278 | * an earlier updated pending. Drivers are allowed to support a queue |
| 2279 | * of outstanding updates, but currently no driver supports that. |
| 2280 | * Note that drivers must wait for preceding updates to complete if a |
| 2281 | * synchronous update is requested, they are not allowed to fail the |
| 2282 | * commit in that case. |
| 2283 | * |
| 2284 | * - -ENOMEM, if the driver failed to allocate memory. Specifically |
| 2285 | * this can happen when trying to pin framebuffers, which must only |
| 2286 | * be done when committing the state. |
| 2287 | * |
| 2288 | * - -ENOSPC, as a refinement of the more generic -ENOMEM to indicate |
| 2289 | * that the driver has run out of vram, iommu space or similar GPU |
| 2290 | * address space needed for framebuffer. |
| 2291 | * |
| 2292 | * - -EIO, if the hardware completely died. |
| 2293 | * |
| 2294 | * - -EINTR, -EAGAIN or -ERESTARTSYS, if the IOCTL should be restarted. |
| 2295 | * This can either be due to a pending signal, or because the driver |
| 2296 | * needs to completely bail out to recover from an exceptional |
| 2297 | * situation like a GPU hang. From a userspace point of view all errors are |
| 2298 | * treated equally. |
| 2299 | * |
| 2300 | * This list is exhaustive. Specifically this hook is not allowed to |
| 2301 | * return -EINVAL (any invalid requests should be caught in |
| 2302 | * @atomic_check) or -EDEADLK (this function must not acquire |
| 2303 | * additional modeset locks). |
| 2304 | */ |
Daniel Vetter | cc4ceb4 | 2014-07-25 21:30:38 +0200 | [diff] [blame] | 2305 | int (*atomic_commit)(struct drm_device *dev, |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 2306 | struct drm_atomic_state *state, |
Maarten Lankhorst | 286dbb8 | 2016-04-26 16:11:34 +0200 | [diff] [blame] | 2307 | bool nonblock); |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 2308 | |
| 2309 | /** |
| 2310 | * @atomic_state_alloc: |
| 2311 | * |
| 2312 | * This optional hook can be used by drivers that want to subclass struct |
| 2313 | * &drm_atomic_state to be able to track their own driver-private global |
| 2314 | * state easily. If this hook is implemented, drivers must also |
| 2315 | * implement @atomic_state_clear and @atomic_state_free. |
| 2316 | * |
| 2317 | * RETURNS: |
| 2318 | * |
| 2319 | * A new &drm_atomic_state on success or NULL on failure. |
| 2320 | */ |
Maarten Lankhorst | 036ef57 | 2015-05-18 10:06:40 +0200 | [diff] [blame] | 2321 | struct drm_atomic_state *(*atomic_state_alloc)(struct drm_device *dev); |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 2322 | |
| 2323 | /** |
| 2324 | * @atomic_state_clear: |
| 2325 | * |
| 2326 | * This hook must clear any driver private state duplicated into the |
| 2327 | * passed-in &drm_atomic_state. This hook is called when the caller |
| 2328 | * encountered a &drm_modeset_lock deadlock and needs to drop all |
| 2329 | * already acquired locks as part of the deadlock avoidance dance |
| 2330 | * implemented in drm_modeset_lock_backoff(). |
| 2331 | * |
| 2332 | * Any duplicated state must be invalidated since a concurrent atomic |
| 2333 | * update might change it, and the drm atomic interfaces always apply |
| 2334 | * updates as relative changes to the current state. |
| 2335 | * |
| 2336 | * Drivers that implement this must call drm_atomic_state_default_clear() |
| 2337 | * to clear common state. |
| 2338 | */ |
Maarten Lankhorst | 036ef57 | 2015-05-18 10:06:40 +0200 | [diff] [blame] | 2339 | void (*atomic_state_clear)(struct drm_atomic_state *state); |
Daniel Vetter | 9953f41 | 2015-12-04 09:46:02 +0100 | [diff] [blame] | 2340 | |
| 2341 | /** |
| 2342 | * @atomic_state_free: |
| 2343 | * |
| 2344 | * This hook needs driver private resources and the &drm_atomic_state |
| 2345 | * itself. Note that the core first calls drm_atomic_state_clear() to |
| 2346 | * avoid code duplicate between the clear and free hooks. |
| 2347 | * |
| 2348 | * Drivers that implement this must call drm_atomic_state_default_free() |
| 2349 | * to release common resources. |
| 2350 | */ |
Maarten Lankhorst | 036ef57 | 2015-05-18 10:06:40 +0200 | [diff] [blame] | 2351 | void (*atomic_state_free)(struct drm_atomic_state *state); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2352 | }; |
| 2353 | |
Jesse Barnes | c1aaca2 | 2011-11-07 12:03:21 -0800 | [diff] [blame] | 2354 | /** |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 2355 | * struct drm_mode_config - Mode configuration control structure |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 2356 | * @mutex: mutex protecting KMS related lists and structures |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 2357 | * @connection_mutex: ww mutex protecting connector state and routing |
| 2358 | * @acquire_ctx: global implicit acquire context used by atomic drivers for |
Daniel Vetter | c6b0ca3 | 2015-12-04 09:46:01 +0100 | [diff] [blame] | 2359 | * legacy IOCTLs |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 2360 | * @fb_lock: mutex to protect fb state and lists |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 2361 | * @num_fb: number of fbs available |
| 2362 | * @fb_list: list of framebuffers available |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 2363 | * @num_encoder: number of encoders on this device |
| 2364 | * @encoder_list: list of encoder objects |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 2365 | * @num_overlay_plane: number of overlay planes on this device |
| 2366 | * @num_total_plane: number of universal (i.e. with primary/curso) planes on this device |
| 2367 | * @plane_list: list of plane objects |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 2368 | * @num_crtc: number of CRTCs on this device |
| 2369 | * @crtc_list: list of CRTC objects |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 2370 | * @property_list: list of property objects |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 2371 | * @min_width: minimum pixel width on this device |
| 2372 | * @min_height: minimum pixel height on this device |
| 2373 | * @max_width: maximum pixel width on this device |
| 2374 | * @max_height: maximum pixel height on this device |
| 2375 | * @funcs: core driver provided mode setting functions |
| 2376 | * @fb_base: base address of the framebuffer |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 2377 | * @poll_enabled: track polling support for this device |
| 2378 | * @poll_running: track polling status for this device |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 2379 | * @delayed_event: track delayed poll uevent deliver for this device |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 2380 | * @output_poll_work: delayed work for polling in process context |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 2381 | * @property_blob_list: list of all the blob property objects |
Daniel Stone | 8fb6e7a | 2015-04-20 19:22:54 +0100 | [diff] [blame] | 2382 | * @blob_lock: mutex for blob property allocation and management |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 2383 | * @*_property: core property tracking |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 2384 | * @preferred_depth: preferred RBG pixel depth, used by fb helpers |
| 2385 | * @prefer_shadow: hint to userspace to prefer shadow-fb rendering |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 2386 | * @cursor_width: hint to userspace for max cursor width |
| 2387 | * @cursor_height: hint to userspace for max cursor height |
Daniel Vetter | 9f2a795 | 2016-06-08 14:19:02 +0200 | [diff] [blame] | 2388 | * @helper_private: mid-layer private data |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2389 | * |
Jesse Barnes | a62c93d | 2011-11-07 12:03:22 -0800 | [diff] [blame] | 2390 | * Core mode resource tracking structure. All CRTC, encoders, and connectors |
| 2391 | * enumerated by the driver are added here, as are global properties. Some |
| 2392 | * global restrictions are also here, e.g. dimension restrictions. |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2393 | */ |
| 2394 | struct drm_mode_config { |
Jesse Barnes | ad2563c | 2009-01-19 17:21:45 +1000 | [diff] [blame] | 2395 | struct mutex mutex; /* protects configuration (mode lists etc.) */ |
Rob Clark | 51fd371 | 2013-11-19 12:10:12 -0500 | [diff] [blame] | 2396 | struct drm_modeset_lock connection_mutex; /* protects connector->encoder and encoder->crtc links */ |
| 2397 | struct drm_modeset_acquire_ctx *acquire_ctx; /* for legacy _lock_all() / _unlock_all() */ |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 2398 | |
| 2399 | /** |
| 2400 | * @idr_mutex: |
| 2401 | * |
| 2402 | * Mutex for KMS ID allocation and management. Protects both @crtc_idr |
| 2403 | * and @tile_idr. |
| 2404 | */ |
| 2405 | struct mutex idr_mutex; |
| 2406 | |
| 2407 | /** |
| 2408 | * @crtc_idr: |
| 2409 | * |
| 2410 | * Main KMS ID tracking object. Use this idr for all IDs, fb, crtc, |
| 2411 | * connector, modes - just makes life easier to have only one. |
| 2412 | */ |
| 2413 | struct idr crtc_idr; |
| 2414 | |
| 2415 | /** |
| 2416 | * @tile_idr: |
| 2417 | * |
| 2418 | * Use this idr for allocating new IDs for tiled sinks like use in some |
| 2419 | * high-res DP MST screens. |
| 2420 | */ |
| 2421 | struct idr tile_idr; |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 2422 | |
Daniel Vetter | 2c0c33d | 2014-10-27 20:19:38 +0100 | [diff] [blame] | 2423 | struct mutex fb_lock; /* proctects global and per-file fb lists */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2424 | int num_fb; |
| 2425 | struct list_head fb_list; |
Daniel Vetter | 4b096ac | 2012-12-10 21:19:18 +0100 | [diff] [blame] | 2426 | |
Daniel Vetter | 9609408 | 2016-07-15 21:47:59 +0200 | [diff] [blame] | 2427 | /** |
| 2428 | * @num_connector: Number of connectors on this device. |
| 2429 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2430 | int num_connector; |
Daniel Vetter | 9609408 | 2016-07-15 21:47:59 +0200 | [diff] [blame] | 2431 | /** |
| 2432 | * @connector_ida: ID allocator for connector indices. |
| 2433 | */ |
Maarten Lankhorst | 5fff80b | 2016-02-17 08:32:05 +0100 | [diff] [blame] | 2434 | struct ida connector_ida; |
Daniel Vetter | 9609408 | 2016-07-15 21:47:59 +0200 | [diff] [blame] | 2435 | /** |
| 2436 | * @connector_list: List of connector objects. |
| 2437 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2438 | struct list_head connector_list; |
| 2439 | int num_encoder; |
| 2440 | struct list_head encoder_list; |
Matt Roper | e27dde3 | 2014-04-01 15:22:30 -0700 | [diff] [blame] | 2441 | |
| 2442 | /* |
| 2443 | * Track # of overlay planes separately from # of total planes. By |
| 2444 | * default we only advertise overlay planes to userspace; if userspace |
| 2445 | * sets the "universal plane" capability bit, we'll go ahead and |
| 2446 | * expose all planes. |
| 2447 | */ |
| 2448 | int num_overlay_plane; |
| 2449 | int num_total_plane; |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 2450 | struct list_head plane_list; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2451 | |
| 2452 | int num_crtc; |
| 2453 | struct list_head crtc_list; |
| 2454 | |
| 2455 | struct list_head property_list; |
| 2456 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2457 | int min_width, min_height; |
| 2458 | int max_width, max_height; |
Laurent Pinchart | e6ecefa | 2012-05-17 13:27:23 +0200 | [diff] [blame] | 2459 | const struct drm_mode_config_funcs *funcs; |
Benjamin Herrenschmidt | d883f7f | 2009-02-02 16:55:45 +1100 | [diff] [blame] | 2460 | resource_size_t fb_base; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2461 | |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 2462 | /* output poll support */ |
| 2463 | bool poll_enabled; |
Daniel Vetter | 905bc9f | 2012-10-23 18:23:36 +0000 | [diff] [blame] | 2464 | bool poll_running; |
Daniel Vetter | 162b6a5 | 2015-01-21 08:45:21 +0100 | [diff] [blame] | 2465 | bool delayed_event; |
Tejun Heo | 991ea75 | 2010-07-20 22:09:02 +0200 | [diff] [blame] | 2466 | struct delayed_work output_poll_work; |
Dave Airlie | eb1f8e4 | 2010-05-07 06:42:51 +0000 | [diff] [blame] | 2467 | |
Daniel Stone | 8fb6e7a | 2015-04-20 19:22:54 +0100 | [diff] [blame] | 2468 | struct mutex blob_lock; |
| 2469 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2470 | /* pointers to standard properties */ |
| 2471 | struct list_head property_blob_list; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2472 | /** |
| 2473 | * @edid_property: Default connector property to hold the EDID of the |
| 2474 | * currently connected sink, if any. |
| 2475 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2476 | struct drm_property *edid_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2477 | /** |
| 2478 | * @dpms_property: Default connector property to control the |
| 2479 | * connector's DPMS state. |
| 2480 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2481 | struct drm_property *dpms_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2482 | /** |
| 2483 | * @path_property: Default connector property to hold the DP MST path |
| 2484 | * for the port. |
| 2485 | */ |
Dave Airlie | 43aba7e | 2014-06-05 14:01:31 +1000 | [diff] [blame] | 2486 | struct drm_property *path_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2487 | /** |
| 2488 | * @tile_property: Default connector property to store the tile |
| 2489 | * position of a tiled screen, for sinks which need to be driven with |
| 2490 | * multiple CRTCs. |
| 2491 | */ |
Dave Airlie | 6f134d7 | 2014-10-20 16:30:50 +1000 | [diff] [blame] | 2492 | struct drm_property *tile_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2493 | /** |
| 2494 | * @plane_type_property: Default plane property to differentiate |
| 2495 | * CURSOR, PRIMARY and OVERLAY legacy uses of planes. |
| 2496 | */ |
Rob Clark | 9922ab5 | 2014-04-01 20:16:57 -0400 | [diff] [blame] | 2497 | struct drm_property *plane_type_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2498 | /** |
| 2499 | * @rotation_property: Optional property for planes or CRTCs to specifiy |
| 2500 | * rotation. |
| 2501 | */ |
Sonika Jindal | 2a297cc | 2014-08-05 11:26:54 +0530 | [diff] [blame] | 2502 | struct drm_property *rotation_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2503 | /** |
| 2504 | * @prop_src_x: Default atomic plane property for the plane source |
| 2505 | * position in the connected &drm_framebuffer. |
| 2506 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 2507 | struct drm_property *prop_src_x; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2508 | /** |
| 2509 | * @prop_src_y: Default atomic plane property for the plane source |
| 2510 | * position in the connected &drm_framebuffer. |
| 2511 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 2512 | struct drm_property *prop_src_y; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2513 | /** |
| 2514 | * @prop_src_w: Default atomic plane property for the plane source |
| 2515 | * position in the connected &drm_framebuffer. |
| 2516 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 2517 | struct drm_property *prop_src_w; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2518 | /** |
| 2519 | * @prop_src_h: Default atomic plane property for the plane source |
| 2520 | * position in the connected &drm_framebuffer. |
| 2521 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 2522 | struct drm_property *prop_src_h; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2523 | /** |
| 2524 | * @prop_crtc_x: Default atomic plane property for the plane destination |
| 2525 | * position in the &drm_crtc is is being shown on. |
| 2526 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 2527 | struct drm_property *prop_crtc_x; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2528 | /** |
| 2529 | * @prop_crtc_y: Default atomic plane property for the plane destination |
| 2530 | * position in the &drm_crtc is is being shown on. |
| 2531 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 2532 | struct drm_property *prop_crtc_y; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2533 | /** |
| 2534 | * @prop_crtc_w: Default atomic plane property for the plane destination |
| 2535 | * position in the &drm_crtc is is being shown on. |
| 2536 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 2537 | struct drm_property *prop_crtc_w; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2538 | /** |
| 2539 | * @prop_crtc_h: Default atomic plane property for the plane destination |
| 2540 | * position in the &drm_crtc is is being shown on. |
| 2541 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 2542 | struct drm_property *prop_crtc_h; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2543 | /** |
| 2544 | * @prop_fb_id: Default atomic plane property to specify the |
| 2545 | * &drm_framebuffer. |
| 2546 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 2547 | struct drm_property *prop_fb_id; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2548 | /** |
| 2549 | * @prop_crtc_id: Default atomic plane property to specify the |
| 2550 | * &drm_crtc. |
| 2551 | */ |
Rob Clark | 6b4959f | 2014-12-18 16:01:53 -0500 | [diff] [blame] | 2552 | struct drm_property *prop_crtc_id; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2553 | /** |
| 2554 | * @prop_active: Default atomic CRTC property to control the active |
| 2555 | * state, which is the simplified implementation for DPMS in atomic |
| 2556 | * drivers. |
| 2557 | */ |
Daniel Vetter | eab3bbe | 2015-01-22 16:36:21 +0100 | [diff] [blame] | 2558 | struct drm_property *prop_active; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2559 | /** |
| 2560 | * @prop_mode_id: Default atomic CRTC property to set the mode for a |
| 2561 | * CRTC. A 0 mode implies that the CRTC is entirely disabled - all |
| 2562 | * connectors must be of and active must be set to disabled, too. |
| 2563 | */ |
Daniel Stone | 955f3c3 | 2015-05-25 19:11:52 +0100 | [diff] [blame] | 2564 | struct drm_property *prop_mode_id; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2565 | |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2566 | /** |
| 2567 | * @dvi_i_subconnector_property: Optional DVI-I property to |
| 2568 | * differentiate between analog or digital mode. |
| 2569 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2570 | struct drm_property *dvi_i_subconnector_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2571 | /** |
| 2572 | * @dvi_i_select_subconnector_property: Optional DVI-I property to |
| 2573 | * select between analog or digital mode. |
| 2574 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2575 | struct drm_property *dvi_i_select_subconnector_property; |
| 2576 | |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2577 | /** |
| 2578 | * @tv_subconnector_property: Optional TV property to differentiate |
| 2579 | * between different TV connector types. |
| 2580 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2581 | struct drm_property *tv_subconnector_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2582 | /** |
| 2583 | * @tv_select_subconnector_property: Optional TV property to select |
| 2584 | * between different TV connector types. |
| 2585 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2586 | struct drm_property *tv_select_subconnector_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2587 | /** |
| 2588 | * @tv_mode_property: Optional TV property to select |
| 2589 | * the output TV mode. |
| 2590 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2591 | struct drm_property *tv_mode_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2592 | /** |
| 2593 | * @tv_left_margin_property: Optional TV property to set the left |
| 2594 | * margin. |
| 2595 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2596 | struct drm_property *tv_left_margin_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2597 | /** |
| 2598 | * @tv_right_margin_property: Optional TV property to set the right |
| 2599 | * margin. |
| 2600 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2601 | struct drm_property *tv_right_margin_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2602 | /** |
| 2603 | * @tv_top_margin_property: Optional TV property to set the right |
| 2604 | * margin. |
| 2605 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2606 | struct drm_property *tv_top_margin_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2607 | /** |
| 2608 | * @tv_bottom_margin_property: Optional TV property to set the right |
| 2609 | * margin. |
| 2610 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2611 | struct drm_property *tv_bottom_margin_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2612 | /** |
| 2613 | * @tv_brightness_property: Optional TV property to set the |
| 2614 | * brightness. |
| 2615 | */ |
Francisco Jerez | b6b7902 | 2009-08-02 04:19:20 +0200 | [diff] [blame] | 2616 | struct drm_property *tv_brightness_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2617 | /** |
| 2618 | * @tv_contrast_property: Optional TV property to set the |
| 2619 | * contrast. |
| 2620 | */ |
Francisco Jerez | b6b7902 | 2009-08-02 04:19:20 +0200 | [diff] [blame] | 2621 | struct drm_property *tv_contrast_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2622 | /** |
| 2623 | * @tv_flicker_reduction_property: Optional TV property to control the |
| 2624 | * flicker reduction mode. |
| 2625 | */ |
Francisco Jerez | b6b7902 | 2009-08-02 04:19:20 +0200 | [diff] [blame] | 2626 | struct drm_property *tv_flicker_reduction_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2627 | /** |
| 2628 | * @tv_overscan_property: Optional TV property to control the overscan |
| 2629 | * setting. |
| 2630 | */ |
Francisco Jerez | a75f023 | 2009-08-12 02:30:10 +0200 | [diff] [blame] | 2631 | struct drm_property *tv_overscan_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2632 | /** |
| 2633 | * @tv_saturation_property: Optional TV property to set the |
| 2634 | * saturation. |
| 2635 | */ |
Francisco Jerez | a75f023 | 2009-08-12 02:30:10 +0200 | [diff] [blame] | 2636 | struct drm_property *tv_saturation_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2637 | /** |
| 2638 | * @tv_hue_property: Optional TV property to set the hue. |
| 2639 | */ |
Francisco Jerez | a75f023 | 2009-08-12 02:30:10 +0200 | [diff] [blame] | 2640 | struct drm_property *tv_hue_property; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2641 | |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2642 | /** |
| 2643 | * @scaling_mode_property: Optional connector property to control the |
| 2644 | * upscaling, mostly used for built-in panels. |
| 2645 | */ |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2646 | struct drm_property *scaling_mode_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2647 | /** |
| 2648 | * @aspect_ratio_property: Optional connector property to control the |
| 2649 | * HDMI infoframe aspect ratio setting. |
| 2650 | */ |
Vandana Kannan | ff587e4 | 2014-06-11 10:46:48 +0530 | [diff] [blame] | 2651 | struct drm_property *aspect_ratio_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2652 | /** |
| 2653 | * @dirty_info_property: Optional connector property to give userspace a |
| 2654 | * hint that the DIRTY_FB ioctl should be used. |
| 2655 | */ |
Jakob Bornecrantz | 884840a | 2009-12-03 23:25:47 +0000 | [diff] [blame] | 2656 | struct drm_property *dirty_info_property; |
Dave Airlie | 019d96c | 2011-09-29 16:20:42 +0100 | [diff] [blame] | 2657 | |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2658 | /** |
| 2659 | * @degamma_lut_property: Optional CRTC property to set the LUT used to |
| 2660 | * convert the framebuffer's colors to linear gamma. |
| 2661 | */ |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 2662 | struct drm_property *degamma_lut_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2663 | /** |
| 2664 | * @degamma_lut_size_property: Optional CRTC property for the size of |
| 2665 | * the degamma LUT as supported by the driver (read-only). |
| 2666 | */ |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 2667 | struct drm_property *degamma_lut_size_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2668 | /** |
| 2669 | * @ctm_property: Optional CRTC property to set the |
| 2670 | * matrix used to convert colors after the lookup in the |
| 2671 | * degamma LUT. |
| 2672 | */ |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 2673 | struct drm_property *ctm_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2674 | /** |
| 2675 | * @gamma_lut_property: Optional CRTC property to set the LUT used to |
| 2676 | * convert the colors, after the CTM matrix, to the gamma space of the |
| 2677 | * connected screen. |
| 2678 | */ |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 2679 | struct drm_property *gamma_lut_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2680 | /** |
| 2681 | * @gamma_lut_size_property: Optional CRTC property for the size of the |
| 2682 | * gamma LUT as supported by the driver (read-only). |
| 2683 | */ |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 2684 | struct drm_property *gamma_lut_size_property; |
| 2685 | |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2686 | /** |
| 2687 | * @suggested_x_property: Optional connector property with a hint for |
| 2688 | * the position of the output on the host's screen. |
| 2689 | */ |
Dave Airlie | 5bb2bbf | 2014-11-10 10:18:15 +1000 | [diff] [blame] | 2690 | struct drm_property *suggested_x_property; |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2691 | /** |
| 2692 | * @suggested_y_property: Optional connector property with a hint for |
| 2693 | * the position of the output on the host's screen. |
| 2694 | */ |
Dave Airlie | 5bb2bbf | 2014-11-10 10:18:15 +1000 | [diff] [blame] | 2695 | struct drm_property *suggested_y_property; |
| 2696 | |
Dave Airlie | 019d96c | 2011-09-29 16:20:42 +0100 | [diff] [blame] | 2697 | /* dumb ioctl parameters */ |
| 2698 | uint32_t preferred_depth, prefer_shadow; |
Keith Packard | 62f2104 | 2013-07-22 18:50:00 -0700 | [diff] [blame] | 2699 | |
Daniel Vetter | 9a6bc03 | 2016-07-15 21:48:00 +0200 | [diff] [blame] | 2700 | /** |
| 2701 | * @async_page_flip: Does this device support async flips on the primary |
| 2702 | * plane? |
| 2703 | */ |
Keith Packard | 62f2104 | 2013-07-22 18:50:00 -0700 | [diff] [blame] | 2704 | bool async_page_flip; |
Alex Deucher | 8716ed4 | 2014-02-12 12:48:23 -0500 | [diff] [blame] | 2705 | |
Daniel Vetter | ac3ba4a | 2016-05-31 23:11:10 +0200 | [diff] [blame] | 2706 | /** |
| 2707 | * @allow_fb_modifiers: |
| 2708 | * |
| 2709 | * Whether the driver supports fb modifiers in the ADDFB2.1 ioctl call. |
| 2710 | */ |
Rob Clark | e3eb325 | 2015-02-05 14:41:52 +0000 | [diff] [blame] | 2711 | bool allow_fb_modifiers; |
| 2712 | |
Alex Deucher | 8716ed4 | 2014-02-12 12:48:23 -0500 | [diff] [blame] | 2713 | /* cursor size */ |
| 2714 | uint32_t cursor_width, cursor_height; |
Daniel Vetter | 9f2a795 | 2016-06-08 14:19:02 +0200 | [diff] [blame] | 2715 | |
| 2716 | struct drm_mode_config_helper_funcs *helper_private; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2717 | }; |
| 2718 | |
Rob Clark | dd27595 | 2014-11-25 20:29:46 -0500 | [diff] [blame] | 2719 | /** |
| 2720 | * drm_for_each_plane_mask - iterate over planes specified by bitmask |
| 2721 | * @plane: the loop cursor |
| 2722 | * @dev: the DRM device |
| 2723 | * @plane_mask: bitmask of plane indices |
| 2724 | * |
| 2725 | * Iterate over all planes specified by bitmask. |
| 2726 | */ |
| 2727 | #define drm_for_each_plane_mask(plane, dev, plane_mask) \ |
| 2728 | list_for_each_entry((plane), &(dev)->mode_config.plane_list, head) \ |
Jani Nikula | 373701b | 2015-11-24 21:21:55 +0200 | [diff] [blame] | 2729 | for_each_if ((plane_mask) & (1 << drm_plane_index(plane))) |
Rob Clark | dd27595 | 2014-11-25 20:29:46 -0500 | [diff] [blame] | 2730 | |
Maarten Lankhorst | ead8b66 | 2016-01-07 10:59:19 +0100 | [diff] [blame] | 2731 | /** |
| 2732 | * drm_for_each_encoder_mask - iterate over encoders specified by bitmask |
| 2733 | * @encoder: the loop cursor |
| 2734 | * @dev: the DRM device |
| 2735 | * @encoder_mask: bitmask of encoder indices |
| 2736 | * |
| 2737 | * Iterate over all encoders specified by bitmask. |
| 2738 | */ |
| 2739 | #define drm_for_each_encoder_mask(encoder, dev, encoder_mask) \ |
| 2740 | list_for_each_entry((encoder), &(dev)->mode_config.encoder_list, head) \ |
| 2741 | for_each_if ((encoder_mask) & (1 << drm_encoder_index(encoder))) |
Rob Clark | dd27595 | 2014-11-25 20:29:46 -0500 | [diff] [blame] | 2742 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2743 | #define obj_to_crtc(x) container_of(x, struct drm_crtc, base) |
| 2744 | #define obj_to_connector(x) container_of(x, struct drm_connector, base) |
| 2745 | #define obj_to_encoder(x) container_of(x, struct drm_encoder, base) |
| 2746 | #define obj_to_mode(x) container_of(x, struct drm_display_mode, base) |
| 2747 | #define obj_to_fb(x) container_of(x, struct drm_framebuffer, base) |
| 2748 | #define obj_to_property(x) container_of(x, struct drm_property, base) |
| 2749 | #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] | 2750 | #define obj_to_plane(x) container_of(x, struct drm_plane, base) |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2751 | |
Sascha Hauer | 4a67d39 | 2012-02-06 10:58:17 +0100 | [diff] [blame] | 2752 | struct drm_prop_enum_list { |
| 2753 | int type; |
| 2754 | char *name; |
| 2755 | }; |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2756 | |
Ville Syrjälä | f988287 | 2015-12-09 16:19:31 +0200 | [diff] [blame] | 2757 | extern __printf(6, 7) |
| 2758 | int drm_crtc_init_with_planes(struct drm_device *dev, |
| 2759 | struct drm_crtc *crtc, |
| 2760 | struct drm_plane *primary, |
| 2761 | struct drm_plane *cursor, |
| 2762 | const struct drm_crtc_funcs *funcs, |
| 2763 | const char *name, ...); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2764 | extern void drm_crtc_cleanup(struct drm_crtc *crtc); |
Chris Wilson | 490d3d1 | 2016-05-27 20:05:00 +0100 | [diff] [blame] | 2765 | |
| 2766 | /** |
| 2767 | * drm_crtc_index - find the index of a registered CRTC |
| 2768 | * @crtc: CRTC to find index for |
| 2769 | * |
| 2770 | * Given a registered CRTC, return the index of that CRTC within a DRM |
| 2771 | * device's list of CRTCs. |
| 2772 | */ |
| 2773 | static inline unsigned int drm_crtc_index(struct drm_crtc *crtc) |
| 2774 | { |
| 2775 | return crtc->index; |
| 2776 | } |
Russell King | db5f7a6 | 2014-01-02 21:27:33 +0000 | [diff] [blame] | 2777 | |
| 2778 | /** |
| 2779 | * drm_crtc_mask - find the mask of a registered CRTC |
| 2780 | * @crtc: CRTC to find mask for |
| 2781 | * |
| 2782 | * Given a registered CRTC, return the mask bit of that CRTC for an |
| 2783 | * encoder's possible_crtcs field. |
| 2784 | */ |
| 2785 | static inline uint32_t drm_crtc_mask(struct drm_crtc *crtc) |
| 2786 | { |
| 2787 | return 1 << drm_crtc_index(crtc); |
| 2788 | } |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2789 | |
Daniel Vetter | 8106554 | 2016-06-21 10:54:13 +0200 | [diff] [blame] | 2790 | int drm_connector_init(struct drm_device *dev, |
| 2791 | struct drm_connector *connector, |
| 2792 | const struct drm_connector_funcs *funcs, |
| 2793 | int connector_type); |
Thomas Wood | 34ea3d3 | 2014-05-29 16:57:41 +0100 | [diff] [blame] | 2794 | int drm_connector_register(struct drm_connector *connector); |
| 2795 | void drm_connector_unregister(struct drm_connector *connector); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2796 | |
| 2797 | extern void drm_connector_cleanup(struct drm_connector *connector); |
Maarten Lankhorst | 5fff80b | 2016-02-17 08:32:05 +0100 | [diff] [blame] | 2798 | static inline unsigned drm_connector_index(struct drm_connector *connector) |
| 2799 | { |
Daniel Vetter | 6942559 | 2016-07-19 18:25:01 +0200 | [diff] [blame] | 2800 | return connector->index; |
Maarten Lankhorst | 5fff80b | 2016-02-17 08:32:05 +0100 | [diff] [blame] | 2801 | } |
| 2802 | |
Ville Syrjälä | 13a3d91 | 2015-12-09 16:20:18 +0200 | [diff] [blame] | 2803 | extern __printf(5, 6) |
| 2804 | int drm_encoder_init(struct drm_device *dev, |
| 2805 | struct drm_encoder *encoder, |
| 2806 | const struct drm_encoder_funcs *funcs, |
| 2807 | int encoder_type, const char *name, ...); |
Chris Wilson | 490d3d1 | 2016-05-27 20:05:00 +0100 | [diff] [blame] | 2808 | |
| 2809 | /** |
| 2810 | * drm_encoder_index - find the index of a registered encoder |
| 2811 | * @encoder: encoder to find index for |
| 2812 | * |
| 2813 | * Given a registered encoder, return the index of that encoder within a DRM |
| 2814 | * device's list of encoders. |
| 2815 | */ |
| 2816 | static inline unsigned int drm_encoder_index(struct drm_encoder *encoder) |
| 2817 | { |
| 2818 | return encoder->index; |
| 2819 | } |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2820 | |
Thierry Reding | 3d88736 | 2014-01-13 14:33:20 +0100 | [diff] [blame] | 2821 | /** |
| 2822 | * drm_encoder_crtc_ok - can a given crtc drive a given encoder? |
| 2823 | * @encoder: encoder to test |
| 2824 | * @crtc: crtc to test |
| 2825 | * |
| 2826 | * Return false if @encoder can't be driven by @crtc, true otherwise. |
| 2827 | */ |
| 2828 | static inline bool drm_encoder_crtc_ok(struct drm_encoder *encoder, |
| 2829 | struct drm_crtc *crtc) |
| 2830 | { |
| 2831 | return !!(encoder->possible_crtcs & drm_crtc_mask(crtc)); |
| 2832 | } |
| 2833 | |
Ville Syrjälä | b0b3b79 | 2015-12-09 16:19:55 +0200 | [diff] [blame] | 2834 | extern __printf(8, 9) |
| 2835 | int drm_universal_plane_init(struct drm_device *dev, |
| 2836 | struct drm_plane *plane, |
| 2837 | unsigned long possible_crtcs, |
| 2838 | const struct drm_plane_funcs *funcs, |
| 2839 | const uint32_t *formats, |
| 2840 | unsigned int format_count, |
| 2841 | enum drm_plane_type type, |
| 2842 | const char *name, ...); |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 2843 | extern int drm_plane_init(struct drm_device *dev, |
| 2844 | struct drm_plane *plane, |
| 2845 | unsigned long possible_crtcs, |
| 2846 | const struct drm_plane_funcs *funcs, |
Thierry Reding | 45e3743 | 2015-08-12 16:54:28 +0200 | [diff] [blame] | 2847 | const uint32_t *formats, unsigned int format_count, |
Matt Roper | dc415ff | 2014-04-01 15:22:36 -0700 | [diff] [blame] | 2848 | bool is_primary); |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 2849 | extern void drm_plane_cleanup(struct drm_plane *plane); |
Chris Wilson | 490d3d1 | 2016-05-27 20:05:00 +0100 | [diff] [blame] | 2850 | |
| 2851 | /** |
| 2852 | * drm_plane_index - find the index of a registered plane |
| 2853 | * @plane: plane to find index for |
| 2854 | * |
| 2855 | * Given a registered plane, return the index of that plane within a DRM |
| 2856 | * device's list of planes. |
| 2857 | */ |
| 2858 | static inline unsigned int drm_plane_index(struct drm_plane *plane) |
| 2859 | { |
| 2860 | return plane->index; |
| 2861 | } |
Chandra Konduru | f81338a | 2015-04-09 17:36:21 -0700 | [diff] [blame] | 2862 | 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] | 2863 | extern void drm_plane_force_disable(struct drm_plane *plane); |
Gustavo Padovan | ecb7e16 | 2014-12-01 15:40:09 -0800 | [diff] [blame] | 2864 | extern void drm_crtc_get_hv_timing(const struct drm_display_mode *mode, |
| 2865 | int *hdisplay, int *vdisplay); |
Lukas Wunner | 6a0d952 | 2016-06-08 18:47:27 +0200 | [diff] [blame] | 2866 | extern int drm_crtc_force_disable(struct drm_crtc *crtc); |
| 2867 | extern int drm_crtc_force_disable_all(struct drm_device *dev); |
Jesse Barnes | 8cf5c91 | 2011-11-14 14:51:27 -0800 | [diff] [blame] | 2868 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2869 | extern void drm_encoder_cleanup(struct drm_encoder *encoder); |
| 2870 | |
Ville Syrjälä | d20d317 | 2013-06-07 15:43:07 +0000 | [diff] [blame] | 2871 | 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] | 2872 | 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] | 2873 | extern const char *drm_get_dpms_name(int val); |
| 2874 | extern const char *drm_get_dvi_i_subconnector_name(int val); |
| 2875 | extern const char *drm_get_dvi_i_select_name(int val); |
| 2876 | extern const char *drm_get_tv_subconnector_name(int val); |
| 2877 | extern const char *drm_get_tv_select_name(int val); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2878 | extern void drm_mode_config_init(struct drm_device *dev); |
Chris Wilson | eb03355 | 2011-01-24 15:11:08 +0000 | [diff] [blame] | 2879 | extern void drm_mode_config_reset(struct drm_device *dev); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2880 | extern void drm_mode_config_cleanup(struct drm_device *dev); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2881 | |
Dave Airlie | 43aba7e | 2014-06-05 14:01:31 +1000 | [diff] [blame] | 2882 | extern int drm_mode_connector_set_path_property(struct drm_connector *connector, |
Thierry Reding | 12e6cec | 2014-05-13 11:38:36 +0200 | [diff] [blame] | 2883 | const char *path); |
Dave Airlie | 6f134d7 | 2014-10-20 16:30:50 +1000 | [diff] [blame] | 2884 | int drm_mode_connector_set_tile_property(struct drm_connector *connector); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2885 | extern int drm_mode_connector_update_edid_property(struct drm_connector *connector, |
Thierry Reding | 12e6cec | 2014-05-13 11:38:36 +0200 | [diff] [blame] | 2886 | const struct edid *edid); |
Rob Clark | 5ea22f2 | 2014-05-30 11:34:01 -0400 | [diff] [blame] | 2887 | |
Boris Brezillon | b5571e9 | 2014-07-22 12:09:10 +0200 | [diff] [blame] | 2888 | extern int drm_display_info_set_bus_formats(struct drm_display_info *info, |
| 2889 | const u32 *formats, |
| 2890 | unsigned int num_formats); |
| 2891 | |
Rob Clark | 5ea22f2 | 2014-05-30 11:34:01 -0400 | [diff] [blame] | 2892 | static inline bool drm_property_type_is(struct drm_property *property, |
| 2893 | uint32_t type) |
| 2894 | { |
| 2895 | /* instanceof for props.. handles extended type vs original types: */ |
| 2896 | if (property->flags & DRM_MODE_PROP_EXTENDED_TYPE) |
| 2897 | return (property->flags & DRM_MODE_PROP_EXTENDED_TYPE) == type; |
| 2898 | return property->flags & type; |
| 2899 | } |
| 2900 | |
Paulo Zanoni | c543188 | 2012-05-15 18:09:02 -0300 | [diff] [blame] | 2901 | extern int drm_object_property_set_value(struct drm_mode_object *obj, |
| 2902 | struct drm_property *property, |
| 2903 | uint64_t val); |
| 2904 | extern int drm_object_property_get_value(struct drm_mode_object *obj, |
| 2905 | struct drm_property *property, |
| 2906 | uint64_t *value); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2907 | extern int drm_framebuffer_init(struct drm_device *dev, |
| 2908 | struct drm_framebuffer *fb, |
| 2909 | const struct drm_framebuffer_funcs *funcs); |
Daniel Vetter | 786b99e | 2012-12-02 21:53:40 +0100 | [diff] [blame] | 2910 | extern struct drm_framebuffer *drm_framebuffer_lookup(struct drm_device *dev, |
| 2911 | uint32_t id); |
Rob Clark | f7eff60 | 2012-09-05 21:48:38 +0000 | [diff] [blame] | 2912 | extern void drm_framebuffer_remove(struct drm_framebuffer *fb); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2913 | extern void drm_framebuffer_cleanup(struct drm_framebuffer *fb); |
Daniel Vetter | 3620636 | 2012-12-10 20:42:17 +0100 | [diff] [blame] | 2914 | extern void drm_framebuffer_unregister_private(struct drm_framebuffer *fb); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2915 | |
Paulo Zanoni | c543188 | 2012-05-15 18:09:02 -0300 | [diff] [blame] | 2916 | extern void drm_object_attach_property(struct drm_mode_object *obj, |
| 2917 | struct drm_property *property, |
| 2918 | uint64_t init_val); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2919 | extern struct drm_property *drm_property_create(struct drm_device *dev, int flags, |
| 2920 | const char *name, int num_values); |
Sascha Hauer | 4a67d39 | 2012-02-06 10:58:17 +0100 | [diff] [blame] | 2921 | extern struct drm_property *drm_property_create_enum(struct drm_device *dev, int flags, |
| 2922 | const char *name, |
| 2923 | const struct drm_prop_enum_list *props, |
| 2924 | int num_values); |
Rob Clark | 49e2754 | 2012-05-17 02:23:26 -0600 | [diff] [blame] | 2925 | struct drm_property *drm_property_create_bitmask(struct drm_device *dev, |
| 2926 | int flags, const char *name, |
| 2927 | const struct drm_prop_enum_list *props, |
Ville Syrjälä | 7689ffb | 2014-07-08 10:31:52 +0530 | [diff] [blame] | 2928 | int num_props, |
| 2929 | uint64_t supported_bits); |
Sascha Hauer | d9bc3c0 | 2012-02-06 10:58:18 +0100 | [diff] [blame] | 2930 | struct drm_property *drm_property_create_range(struct drm_device *dev, int flags, |
| 2931 | const char *name, |
| 2932 | uint64_t min, uint64_t max); |
Rob Clark | ebc44cf | 2012-09-12 22:22:31 -0500 | [diff] [blame] | 2933 | struct drm_property *drm_property_create_signed_range(struct drm_device *dev, |
| 2934 | int flags, const char *name, |
| 2935 | int64_t min, int64_t max); |
Rob Clark | 98f75de | 2014-05-30 11:37:03 -0400 | [diff] [blame] | 2936 | struct drm_property *drm_property_create_object(struct drm_device *dev, |
| 2937 | int flags, const char *name, uint32_t type); |
Daniel Vetter | 960cd9d | 2015-01-21 08:47:38 +0100 | [diff] [blame] | 2938 | struct drm_property *drm_property_create_bool(struct drm_device *dev, int flags, |
| 2939 | const char *name); |
Daniel Stone | 6bcacf5 | 2015-04-20 19:22:55 +0100 | [diff] [blame] | 2940 | struct drm_property_blob *drm_property_create_blob(struct drm_device *dev, |
| 2941 | size_t length, |
| 2942 | const void *data); |
| 2943 | struct drm_property_blob *drm_property_lookup_blob(struct drm_device *dev, |
| 2944 | uint32_t id); |
| 2945 | struct drm_property_blob *drm_property_reference_blob(struct drm_property_blob *blob); |
| 2946 | void drm_property_unreference_blob(struct drm_property_blob *blob); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2947 | extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property); |
| 2948 | extern int drm_property_add_enum(struct drm_property *property, int index, |
| 2949 | uint64_t value, const char *name); |
| 2950 | extern int drm_mode_create_dvi_i_properties(struct drm_device *dev); |
Thierry Reding | 2f76331 | 2014-10-13 12:45:57 +0200 | [diff] [blame] | 2951 | extern int drm_mode_create_tv_properties(struct drm_device *dev, |
| 2952 | unsigned int num_modes, |
Ville Syrjälä | b7c914b | 2015-08-31 15:09:26 +0300 | [diff] [blame] | 2953 | const char * const modes[]); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2954 | extern int drm_mode_create_scaling_mode_property(struct drm_device *dev); |
Vandana Kannan | ff587e4 | 2014-06-11 10:46:48 +0530 | [diff] [blame] | 2955 | extern int drm_mode_create_aspect_ratio_property(struct drm_device *dev); |
Jakob Bornecrantz | 884840a | 2009-12-03 23:25:47 +0000 | [diff] [blame] | 2956 | extern int drm_mode_create_dirty_info_property(struct drm_device *dev); |
Dave Airlie | 5bb2bbf | 2014-11-10 10:18:15 +1000 | [diff] [blame] | 2957 | extern int drm_mode_create_suggested_offset_properties(struct drm_device *dev); |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2958 | |
| 2959 | extern int drm_mode_connector_attach_encoder(struct drm_connector *connector, |
| 2960 | struct drm_encoder *encoder); |
Sascha Hauer | 4cae5b8 | 2012-02-01 11:38:23 +0100 | [diff] [blame] | 2961 | extern int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc, |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 2962 | int gamma_size); |
Rob Clark | 98f75de | 2014-05-30 11:37:03 -0400 | [diff] [blame] | 2963 | |
Daniel Vetter | 2d13b67 | 2012-12-11 13:47:23 +0100 | [diff] [blame] | 2964 | extern int drm_mode_set_config_internal(struct drm_mode_set *set); |
Daniel Vetter | 8106554 | 2016-06-21 10:54:13 +0200 | [diff] [blame] | 2965 | |
Jesse Barnes | 308e5bc | 2011-11-14 14:51:28 -0800 | [diff] [blame] | 2966 | extern uint32_t drm_mode_legacy_fb_format(uint32_t bpp, uint32_t depth); |
Dave Airlie | 138f9eb | 2014-10-20 16:17:17 +1000 | [diff] [blame] | 2967 | |
| 2968 | extern struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev, |
| 2969 | char topology[8]); |
| 2970 | extern struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev, |
| 2971 | char topology[8]); |
| 2972 | extern void drm_mode_put_tile_group(struct drm_device *dev, |
| 2973 | struct drm_tile_group *tg); |
Dave Airlie | ff72145b | 2011-02-07 12:16:14 +1000 | [diff] [blame] | 2974 | |
Thomas Wood | 3a5f87c | 2014-08-20 14:45:00 +0100 | [diff] [blame] | 2975 | extern int drm_mode_plane_set_obj_prop(struct drm_plane *plane, |
| 2976 | struct drm_property *property, |
| 2977 | uint64_t value); |
Dave Airlie | 248dbc2 | 2011-11-29 20:02:54 +0000 | [diff] [blame] | 2978 | |
Ville Syrjälä | c1df5f3 | 2014-07-08 10:31:53 +0530 | [diff] [blame] | 2979 | extern struct drm_property *drm_mode_create_rotation_property(struct drm_device *dev, |
| 2980 | unsigned int supported_rotations); |
Ville Syrjälä | 3c9855f | 2014-07-08 10:31:56 +0530 | [diff] [blame] | 2981 | extern unsigned int drm_rotation_simplify(unsigned int rotation, |
| 2982 | unsigned int supported_rotations); |
Jyri Sarha | f8ed34a | 2016-06-07 15:09:14 +0300 | [diff] [blame] | 2983 | extern void drm_crtc_enable_color_mgmt(struct drm_crtc *crtc, |
| 2984 | uint degamma_lut_size, |
| 2985 | bool has_ctm, |
| 2986 | uint gamma_lut_size); |
Marek Szyprowski | 44d1240d | 2016-06-13 11:11:26 +0200 | [diff] [blame] | 2987 | |
| 2988 | int drm_plane_create_zpos_property(struct drm_plane *plane, |
| 2989 | unsigned int zpos, |
| 2990 | unsigned int min, unsigned int max); |
| 2991 | |
| 2992 | int drm_plane_create_zpos_immutable_property(struct drm_plane *plane, |
| 2993 | unsigned int zpos); |
| 2994 | |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 2995 | /* Helpers */ |
Daniel Vetter | 8106554 | 2016-06-21 10:54:13 +0200 | [diff] [blame] | 2996 | struct drm_mode_object *drm_mode_object_find(struct drm_device *dev, |
| 2997 | uint32_t id, uint32_t type); |
| 2998 | void drm_mode_object_reference(struct drm_mode_object *obj); |
| 2999 | void drm_mode_object_unreference(struct drm_mode_object *obj); |
Rob Clark | a2b34e2 | 2013-10-05 16:36:52 -0400 | [diff] [blame] | 3000 | |
| 3001 | static inline struct drm_plane *drm_plane_find(struct drm_device *dev, |
| 3002 | uint32_t id) |
| 3003 | { |
| 3004 | struct drm_mode_object *mo; |
| 3005 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_PLANE); |
| 3006 | return mo ? obj_to_plane(mo) : NULL; |
| 3007 | } |
| 3008 | |
Russell King | 96f60e3 | 2012-08-15 13:59:49 +0100 | [diff] [blame] | 3009 | static inline struct drm_crtc *drm_crtc_find(struct drm_device *dev, |
| 3010 | uint32_t id) |
| 3011 | { |
| 3012 | struct drm_mode_object *mo; |
| 3013 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CRTC); |
| 3014 | return mo ? obj_to_crtc(mo) : NULL; |
| 3015 | } |
| 3016 | |
| 3017 | static inline struct drm_encoder *drm_encoder_find(struct drm_device *dev, |
| 3018 | uint32_t id) |
| 3019 | { |
| 3020 | struct drm_mode_object *mo; |
| 3021 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_ENCODER); |
| 3022 | return mo ? obj_to_encoder(mo) : NULL; |
| 3023 | } |
| 3024 | |
Dave Airlie | b164d31 | 2016-04-27 11:10:09 +1000 | [diff] [blame] | 3025 | /** |
| 3026 | * drm_connector_lookup - lookup connector object |
| 3027 | * @dev: DRM device |
| 3028 | * @id: connector object id |
| 3029 | * |
| 3030 | * This function looks up the connector object specified by id |
| 3031 | * add takes a reference to it. |
| 3032 | */ |
| 3033 | static inline struct drm_connector *drm_connector_lookup(struct drm_device *dev, |
Rob Clark | a2b34e2 | 2013-10-05 16:36:52 -0400 | [diff] [blame] | 3034 | uint32_t id) |
| 3035 | { |
| 3036 | struct drm_mode_object *mo; |
| 3037 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CONNECTOR); |
| 3038 | return mo ? obj_to_connector(mo) : NULL; |
| 3039 | } |
| 3040 | |
| 3041 | static inline struct drm_property *drm_property_find(struct drm_device *dev, |
| 3042 | uint32_t id) |
| 3043 | { |
| 3044 | struct drm_mode_object *mo; |
| 3045 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_PROPERTY); |
| 3046 | return mo ? obj_to_property(mo) : NULL; |
| 3047 | } |
| 3048 | |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 3049 | /* |
| 3050 | * Extract a degamma/gamma LUT value provided by user and round it to the |
| 3051 | * precision supported by the hardware. |
| 3052 | */ |
| 3053 | static inline uint32_t drm_color_lut_extract(uint32_t user_input, |
| 3054 | uint32_t bit_precision) |
| 3055 | { |
Lionel Landwerlin | 644a805 | 2016-03-22 14:10:33 +0000 | [diff] [blame] | 3056 | uint32_t val = user_input; |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 3057 | uint32_t max = 0xffff >> (16 - bit_precision); |
| 3058 | |
Lionel Landwerlin | 644a805 | 2016-03-22 14:10:33 +0000 | [diff] [blame] | 3059 | /* Round only if we're not using full precision. */ |
| 3060 | if (bit_precision < 16) { |
| 3061 | val += 1UL << (16 - bit_precision - 1); |
| 3062 | val >>= 16 - bit_precision; |
| 3063 | } |
Lionel Landwerlin | 5488dc1 | 2016-02-26 17:05:00 +0000 | [diff] [blame] | 3064 | |
| 3065 | return clamp_val(val, 0, max); |
| 3066 | } |
| 3067 | |
Dave Airlie | e76d399 | 2016-05-03 10:17:52 +1000 | [diff] [blame] | 3068 | /** |
Dave Airlie | d0f37cf6 | 2016-04-15 15:10:36 +1000 | [diff] [blame] | 3069 | * drm_framebuffer_reference - incr the fb refcnt |
| 3070 | * @fb: framebuffer |
| 3071 | * |
| 3072 | * This functions increments the fb's refcount. |
| 3073 | */ |
| 3074 | static inline void drm_framebuffer_reference(struct drm_framebuffer *fb) |
| 3075 | { |
| 3076 | drm_mode_object_reference(&fb->base); |
| 3077 | } |
| 3078 | |
| 3079 | /** |
| 3080 | * drm_framebuffer_unreference - unref a framebuffer |
| 3081 | * @fb: framebuffer to unref |
| 3082 | * |
| 3083 | * This functions decrements the fb's refcount and frees it if it drops to zero. |
| 3084 | */ |
| 3085 | static inline void drm_framebuffer_unreference(struct drm_framebuffer *fb) |
| 3086 | { |
| 3087 | drm_mode_object_unreference(&fb->base); |
| 3088 | } |
| 3089 | |
Dave Airlie | 747a598 | 2016-04-15 15:10:35 +1000 | [diff] [blame] | 3090 | /** |
| 3091 | * drm_framebuffer_read_refcount - read the framebuffer reference count. |
| 3092 | * @fb: framebuffer |
| 3093 | * |
| 3094 | * This functions returns the framebuffer's reference count. |
| 3095 | */ |
| 3096 | static inline uint32_t drm_framebuffer_read_refcount(struct drm_framebuffer *fb) |
| 3097 | { |
Dave Airlie | d0f37cf6 | 2016-04-15 15:10:36 +1000 | [diff] [blame] | 3098 | return atomic_read(&fb->base.refcount.refcount); |
Dave Airlie | 747a598 | 2016-04-15 15:10:35 +1000 | [diff] [blame] | 3099 | } |
| 3100 | |
Dave Airlie | b164d31 | 2016-04-27 11:10:09 +1000 | [diff] [blame] | 3101 | /** |
| 3102 | * drm_connector_reference - incr the connector refcnt |
| 3103 | * @connector: connector |
| 3104 | * |
| 3105 | * This function increments the connector's refcount. |
| 3106 | */ |
| 3107 | static inline void drm_connector_reference(struct drm_connector *connector) |
| 3108 | { |
| 3109 | drm_mode_object_reference(&connector->base); |
| 3110 | } |
| 3111 | |
| 3112 | /** |
| 3113 | * drm_connector_unreference - unref a connector |
| 3114 | * @connector: connector to unref |
| 3115 | * |
| 3116 | * This function decrements the connector's refcount and frees it if it drops to zero. |
| 3117 | */ |
| 3118 | static inline void drm_connector_unreference(struct drm_connector *connector) |
| 3119 | { |
| 3120 | drm_mode_object_unreference(&connector->base); |
| 3121 | } |
| 3122 | |
Matt Roper | e27dde3 | 2014-04-01 15:22:30 -0700 | [diff] [blame] | 3123 | /* Plane list iterator for legacy (overlay only) planes. */ |
Daniel Vetter | 4ea50e9 | 2015-07-09 23:44:24 +0200 | [diff] [blame] | 3124 | #define drm_for_each_legacy_plane(plane, dev) \ |
| 3125 | list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) \ |
Jani Nikula | 373701b | 2015-11-24 21:21:55 +0200 | [diff] [blame] | 3126 | for_each_if (plane->type == DRM_PLANE_TYPE_OVERLAY) |
Matt Roper | e27dde3 | 2014-04-01 15:22:30 -0700 | [diff] [blame] | 3127 | |
Daniel Vetter | 6295d60 | 2015-07-09 23:44:25 +0200 | [diff] [blame] | 3128 | #define drm_for_each_plane(plane, dev) \ |
| 3129 | list_for_each_entry(plane, &(dev)->mode_config.plane_list, head) |
| 3130 | |
| 3131 | #define drm_for_each_crtc(crtc, dev) \ |
| 3132 | list_for_each_entry(crtc, &(dev)->mode_config.crtc_list, head) |
| 3133 | |
Daniel Vetter | 7a3f3d6 | 2015-07-09 23:44:28 +0200 | [diff] [blame] | 3134 | static inline void |
| 3135 | assert_drm_connector_list_read_locked(struct drm_mode_config *mode_config) |
| 3136 | { |
Daniel Vetter | cff20ba | 2015-07-09 23:44:33 +0200 | [diff] [blame] | 3137 | /* |
| 3138 | * The connector hotadd/remove code currently grabs both locks when |
| 3139 | * updating lists. Hence readers need only hold either of them to be |
| 3140 | * safe and the check amounts to |
| 3141 | * |
| 3142 | * WARN_ON(not_holding(A) && not_holding(B)). |
| 3143 | */ |
| 3144 | WARN_ON(!mutex_is_locked(&mode_config->mutex) && |
| 3145 | !drm_modeset_is_locked(&mode_config->connection_mutex)); |
Daniel Vetter | 7a3f3d6 | 2015-07-09 23:44:28 +0200 | [diff] [blame] | 3146 | } |
| 3147 | |
Daniel Vetter | 6295d60 | 2015-07-09 23:44:25 +0200 | [diff] [blame] | 3148 | #define drm_for_each_connector(connector, dev) \ |
Daniel Vetter | 7a3f3d6 | 2015-07-09 23:44:28 +0200 | [diff] [blame] | 3149 | for (assert_drm_connector_list_read_locked(&(dev)->mode_config), \ |
| 3150 | connector = list_first_entry(&(dev)->mode_config.connector_list, \ |
| 3151 | struct drm_connector, head); \ |
| 3152 | &connector->head != (&(dev)->mode_config.connector_list); \ |
| 3153 | connector = list_next_entry(connector, head)) |
Daniel Vetter | 6295d60 | 2015-07-09 23:44:25 +0200 | [diff] [blame] | 3154 | |
| 3155 | #define drm_for_each_encoder(encoder, dev) \ |
| 3156 | list_for_each_entry(encoder, &(dev)->mode_config.encoder_list, head) |
| 3157 | |
| 3158 | #define drm_for_each_fb(fb, dev) \ |
Daniel Vetter | 4676ba0 | 2015-07-09 23:44:30 +0200 | [diff] [blame] | 3159 | for (WARN_ON(!mutex_is_locked(&(dev)->mode_config.fb_lock)), \ |
| 3160 | fb = list_first_entry(&(dev)->mode_config.fb_list, \ |
| 3161 | struct drm_framebuffer, head); \ |
| 3162 | &fb->head != (&(dev)->mode_config.fb_list); \ |
| 3163 | fb = list_next_entry(fb, head)) |
Daniel Vetter | 6295d60 | 2015-07-09 23:44:25 +0200 | [diff] [blame] | 3164 | |
Daniel Vetter | 8106554 | 2016-06-21 10:54:13 +0200 | [diff] [blame] | 3165 | /* drm_edid.c */ |
| 3166 | bool drm_probe_ddc(struct i2c_adapter *adapter); |
| 3167 | struct edid *drm_get_edid(struct drm_connector *connector, |
| 3168 | struct i2c_adapter *adapter); |
| 3169 | struct edid *drm_get_edid_switcheroo(struct drm_connector *connector, |
| 3170 | struct i2c_adapter *adapter); |
| 3171 | struct edid *drm_edid_duplicate(const struct edid *edid); |
| 3172 | int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid); |
| 3173 | |
| 3174 | u8 drm_match_cea_mode(const struct drm_display_mode *to_match); |
| 3175 | enum hdmi_picture_aspect drm_get_cea_aspect_ratio(const u8 video_code); |
| 3176 | bool drm_detect_hdmi_monitor(struct edid *edid); |
| 3177 | bool drm_detect_monitor_audio(struct edid *edid); |
| 3178 | bool drm_rgb_quant_range_selectable(struct edid *edid); |
| 3179 | int drm_add_modes_noedid(struct drm_connector *connector, |
| 3180 | int hdisplay, int vdisplay); |
| 3181 | void drm_set_preferred_mode(struct drm_connector *connector, |
| 3182 | int hpref, int vpref); |
| 3183 | |
| 3184 | int drm_edid_header_is_valid(const u8 *raw_edid); |
| 3185 | bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid, |
| 3186 | bool *edid_corrupt); |
| 3187 | bool drm_edid_is_valid(struct edid *edid); |
| 3188 | void drm_edid_get_monitor_name(struct edid *edid, char *name, |
| 3189 | int buflen); |
| 3190 | struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev, |
| 3191 | int hsize, int vsize, int fresh, |
| 3192 | bool rb); |
| 3193 | |
| 3194 | /* drm_bridge.c */ |
| 3195 | extern int drm_bridge_add(struct drm_bridge *bridge); |
| 3196 | extern void drm_bridge_remove(struct drm_bridge *bridge); |
| 3197 | extern struct drm_bridge *of_drm_find_bridge(struct device_node *np); |
| 3198 | extern int drm_bridge_attach(struct drm_device *dev, struct drm_bridge *bridge); |
| 3199 | |
| 3200 | bool drm_bridge_mode_fixup(struct drm_bridge *bridge, |
| 3201 | const struct drm_display_mode *mode, |
| 3202 | struct drm_display_mode *adjusted_mode); |
| 3203 | void drm_bridge_disable(struct drm_bridge *bridge); |
| 3204 | void drm_bridge_post_disable(struct drm_bridge *bridge); |
| 3205 | void drm_bridge_mode_set(struct drm_bridge *bridge, |
| 3206 | struct drm_display_mode *mode, |
| 3207 | struct drm_display_mode *adjusted_mode); |
| 3208 | void drm_bridge_pre_enable(struct drm_bridge *bridge); |
| 3209 | void drm_bridge_enable(struct drm_bridge *bridge); |
| 3210 | |
Dave Airlie | f453ba0 | 2008-11-07 14:05:41 -0800 | [diff] [blame] | 3211 | #endif /* __DRM_CRTC_H__ */ |