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