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