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