Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 Intel Corporation |
| 3 | * |
| 4 | * Permission to use, copy, modify, distribute, and sell this software and its |
| 5 | * documentation for any purpose is hereby granted without fee, provided that |
| 6 | * the above copyright notice appear in all copies and that both that copyright |
| 7 | * notice and this permission notice appear in supporting documentation, and |
| 8 | * that the name of the copyright holders not be used in advertising or |
| 9 | * publicity pertaining to distribution of the software without specific, |
| 10 | * written prior permission. The copyright holders make no representations |
| 11 | * about the suitability of this software for any purpose. It is provided "as |
| 12 | * is" without express or implied warranty. |
| 13 | * |
| 14 | * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, |
| 15 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO |
| 16 | * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR |
| 17 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, |
| 18 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 19 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE |
| 20 | * OF THIS SOFTWARE. |
| 21 | */ |
| 22 | |
| 23 | #ifndef __DRM_CONNECTOR_H__ |
| 24 | #define __DRM_CONNECTOR_H__ |
| 25 | |
| 26 | #include <linux/list.h> |
| 27 | #include <linux/ctype.h> |
Daniel Vetter | 949619f | 2016-08-29 10:27:51 +0200 | [diff] [blame] | 28 | #include <drm/drm_mode_object.h> |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 29 | |
Daniel Vetter | 199e4e9 | 2016-08-31 18:09:05 +0200 | [diff] [blame] | 30 | #include <uapi/drm/drm_mode.h> |
| 31 | |
| 32 | struct drm_device; |
| 33 | |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 34 | struct drm_connector_helper_funcs; |
| 35 | struct drm_device; |
| 36 | struct drm_crtc; |
| 37 | struct drm_encoder; |
| 38 | struct drm_property; |
| 39 | struct drm_property_blob; |
Rob Clark | fceffb32 | 2016-11-05 11:08:09 -0400 | [diff] [blame] | 40 | struct drm_printer; |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 41 | struct edid; |
| 42 | |
| 43 | enum drm_connector_force { |
| 44 | DRM_FORCE_UNSPECIFIED, |
| 45 | DRM_FORCE_OFF, |
| 46 | DRM_FORCE_ON, /* force on analog part normally */ |
| 47 | DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */ |
| 48 | }; |
| 49 | |
Daniel Vetter | ae2a6da | 2016-08-12 22:48:53 +0200 | [diff] [blame] | 50 | /** |
| 51 | * enum drm_connector_status - status for a &drm_connector |
| 52 | * |
| 53 | * This enum is used to track the connector status. There are no separate |
| 54 | * #defines for the uapi! |
| 55 | */ |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 56 | enum drm_connector_status { |
Daniel Vetter | ae2a6da | 2016-08-12 22:48:53 +0200 | [diff] [blame] | 57 | /** |
| 58 | * @connector_status_connected: The connector is definitely connected to |
| 59 | * a sink device, and can be enabled. |
| 60 | */ |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 61 | connector_status_connected = 1, |
Daniel Vetter | ae2a6da | 2016-08-12 22:48:53 +0200 | [diff] [blame] | 62 | /** |
| 63 | * @connector_status_disconnected: The connector isn't connected to a |
| 64 | * sink device which can be autodetect. For digital outputs like DP or |
| 65 | * HDMI (which can be realiable probed) this means there's really |
| 66 | * nothing there. It is driver-dependent whether a connector with this |
| 67 | * status can be lit up or not. |
| 68 | */ |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 69 | connector_status_disconnected = 2, |
Daniel Vetter | ae2a6da | 2016-08-12 22:48:53 +0200 | [diff] [blame] | 70 | /** |
| 71 | * @connector_status_unknown: The connector's status could not be |
| 72 | * reliably detected. This happens when probing would either cause |
| 73 | * flicker (like load-detection when the connector is in use), or when a |
| 74 | * hardware resource isn't available (like when load-detection needs a |
| 75 | * free CRTC). It should be possible to light up the connector with one |
| 76 | * of the listed fallback modes. For default configuration userspace |
| 77 | * should only try to light up connectors with unknown status when |
| 78 | * there's not connector with @connector_status_connected. |
| 79 | */ |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 80 | connector_status_unknown = 3, |
| 81 | }; |
| 82 | |
| 83 | enum subpixel_order { |
| 84 | SubPixelUnknown = 0, |
| 85 | SubPixelHorizontalRGB, |
| 86 | SubPixelHorizontalBGR, |
| 87 | SubPixelVerticalRGB, |
| 88 | SubPixelVerticalBGR, |
| 89 | SubPixelNone, |
| 90 | }; |
| 91 | |
Daniel Vetter | b3c6c8b | 2016-08-12 22:48:55 +0200 | [diff] [blame] | 92 | /** |
Manasi Navare | 40ee6fb | 2016-12-16 12:29:06 +0200 | [diff] [blame] | 93 | * enum drm_link_status - connector's link_status property value |
| 94 | * |
| 95 | * This enum is used as the connector's link status property value. |
| 96 | * It is set to the values defined in uapi. |
| 97 | */ |
| 98 | enum drm_link_status { |
| 99 | DRM_LINK_STATUS_GOOD = DRM_MODE_LINK_STATUS_GOOD, |
| 100 | DRM_LINK_STATUS_BAD = DRM_MODE_LINK_STATUS_BAD, |
| 101 | }; |
| 102 | |
| 103 | /** |
Daniel Vetter | b3c6c8b | 2016-08-12 22:48:55 +0200 | [diff] [blame] | 104 | * struct drm_display_info - runtime data about the connected sink |
| 105 | * |
| 106 | * Describes a given display (e.g. CRT or flat panel) and its limitations. For |
| 107 | * fixed display sinks like built-in panels there's not much difference between |
Daniel Vetter | ea0dd85 | 2016-12-29 21:48:26 +0100 | [diff] [blame] | 108 | * this and &struct drm_connector. But for sinks with a real cable this |
Daniel Vetter | b3c6c8b | 2016-08-12 22:48:55 +0200 | [diff] [blame] | 109 | * structure is meant to describe all the things at the other end of the cable. |
| 110 | * |
| 111 | * For sinks which provide an EDID this can be filled out by calling |
| 112 | * drm_add_edid_modes(). |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 113 | */ |
| 114 | struct drm_display_info { |
Daniel Vetter | b3c6c8b | 2016-08-12 22:48:55 +0200 | [diff] [blame] | 115 | /** |
| 116 | * @name: Name of the display. |
| 117 | */ |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 118 | char name[DRM_DISPLAY_INFO_LEN]; |
| 119 | |
Daniel Vetter | b3c6c8b | 2016-08-12 22:48:55 +0200 | [diff] [blame] | 120 | /** |
| 121 | * @width_mm: Physical width in mm. |
| 122 | */ |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 123 | unsigned int width_mm; |
Daniel Vetter | b3c6c8b | 2016-08-12 22:48:55 +0200 | [diff] [blame] | 124 | /** |
| 125 | * @height_mm: Physical height in mm. |
| 126 | */ |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 127 | unsigned int height_mm; |
| 128 | |
Daniel Vetter | b3c6c8b | 2016-08-12 22:48:55 +0200 | [diff] [blame] | 129 | /** |
| 130 | * @pixel_clock: Maximum pixel clock supported by the sink, in units of |
Peter Meerwald-Stadler | 188f7882 | 2016-12-16 14:24:23 +0100 | [diff] [blame] | 131 | * 100Hz. This mismatches the clock in &drm_display_mode (which is in |
Daniel Vetter | b3c6c8b | 2016-08-12 22:48:55 +0200 | [diff] [blame] | 132 | * kHZ), because that's what the EDID uses as base unit. |
| 133 | */ |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 134 | unsigned int pixel_clock; |
Daniel Vetter | b3c6c8b | 2016-08-12 22:48:55 +0200 | [diff] [blame] | 135 | /** |
| 136 | * @bpc: Maximum bits per color channel. Used by HDMI and DP outputs. |
| 137 | */ |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 138 | unsigned int bpc; |
| 139 | |
Daniel Vetter | b3c6c8b | 2016-08-12 22:48:55 +0200 | [diff] [blame] | 140 | /** |
| 141 | * @subpixel_order: Subpixel order of LCD panels. |
| 142 | */ |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 143 | enum subpixel_order subpixel_order; |
| 144 | |
| 145 | #define DRM_COLOR_FORMAT_RGB444 (1<<0) |
| 146 | #define DRM_COLOR_FORMAT_YCRCB444 (1<<1) |
| 147 | #define DRM_COLOR_FORMAT_YCRCB422 (1<<2) |
| 148 | |
Daniel Vetter | b3c6c8b | 2016-08-12 22:48:55 +0200 | [diff] [blame] | 149 | /** |
| 150 | * @color_formats: HDMI Color formats, selects between RGB and YCrCb |
| 151 | * modes. Used DRM_COLOR_FORMAT\_ defines, which are _not_ the same ones |
| 152 | * as used to describe the pixel format in framebuffers, and also don't |
| 153 | * match the formats in @bus_formats which are shared with v4l. |
| 154 | */ |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 155 | u32 color_formats; |
| 156 | |
Daniel Vetter | b3c6c8b | 2016-08-12 22:48:55 +0200 | [diff] [blame] | 157 | /** |
| 158 | * @bus_formats: Pixel data format on the wire, somewhat redundant with |
| 159 | * @color_formats. Array of size @num_bus_formats encoded using |
| 160 | * MEDIA_BUS_FMT\_ defines shared with v4l and media drivers. |
| 161 | */ |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 162 | const u32 *bus_formats; |
Daniel Vetter | b3c6c8b | 2016-08-12 22:48:55 +0200 | [diff] [blame] | 163 | /** |
| 164 | * @num_bus_formats: Size of @bus_formats array. |
| 165 | */ |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 166 | unsigned int num_bus_formats; |
| 167 | |
| 168 | #define DRM_BUS_FLAG_DE_LOW (1<<0) |
| 169 | #define DRM_BUS_FLAG_DE_HIGH (1<<1) |
| 170 | /* drive data on pos. edge */ |
| 171 | #define DRM_BUS_FLAG_PIXDATA_POSEDGE (1<<2) |
| 172 | /* drive data on neg. edge */ |
| 173 | #define DRM_BUS_FLAG_PIXDATA_NEGEDGE (1<<3) |
| 174 | |
Daniel Vetter | b3c6c8b | 2016-08-12 22:48:55 +0200 | [diff] [blame] | 175 | /** |
| 176 | * @bus_flags: Additional information (like pixel signal polarity) for |
| 177 | * the pixel data on the bus, using DRM_BUS_FLAGS\_ defines. |
| 178 | */ |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 179 | u32 bus_flags; |
| 180 | |
Daniel Vetter | b3c6c8b | 2016-08-12 22:48:55 +0200 | [diff] [blame] | 181 | /** |
Ville Syrjälä | 2a272ca | 2016-09-28 16:51:37 +0300 | [diff] [blame] | 182 | * @max_tmds_clock: Maximum TMDS clock rate supported by the |
| 183 | * sink in kHz. 0 means undefined. |
| 184 | */ |
| 185 | int max_tmds_clock; |
| 186 | |
| 187 | /** |
| 188 | * @dvi_dual: Dual-link DVI sink? |
| 189 | */ |
| 190 | bool dvi_dual; |
| 191 | |
| 192 | /** |
Daniel Vetter | b3c6c8b | 2016-08-12 22:48:55 +0200 | [diff] [blame] | 193 | * @edid_hdmi_dc_modes: Mask of supported hdmi deep color modes. Even |
| 194 | * more stuff redundant with @bus_formats. |
| 195 | */ |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 196 | u8 edid_hdmi_dc_modes; |
| 197 | |
Daniel Vetter | b3c6c8b | 2016-08-12 22:48:55 +0200 | [diff] [blame] | 198 | /** |
| 199 | * @cea_rev: CEA revision of the HDMI sink. |
| 200 | */ |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 201 | u8 cea_rev; |
| 202 | }; |
| 203 | |
Daniel Vetter | b3c6c8b | 2016-08-12 22:48:55 +0200 | [diff] [blame] | 204 | int drm_display_info_set_bus_formats(struct drm_display_info *info, |
| 205 | const u32 *formats, |
| 206 | unsigned int num_formats); |
| 207 | |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 208 | /** |
Boris Brezillon | 299a16b | 2016-12-02 14:48:09 +0100 | [diff] [blame] | 209 | * struct drm_tv_connector_state - TV connector related states |
| 210 | * @subconnector: selected subconnector |
| 211 | * @margins: left/right/top/bottom margins |
| 212 | * @mode: TV mode |
| 213 | * @brightness: brightness in percent |
| 214 | * @contrast: contrast in percent |
| 215 | * @flicker_reduction: flicker reduction in percent |
| 216 | * @overscan: overscan in percent |
| 217 | * @saturation: saturation in percent |
| 218 | * @hue: hue in percent |
| 219 | */ |
| 220 | struct drm_tv_connector_state { |
| 221 | enum drm_mode_subconnector subconnector; |
| 222 | struct { |
| 223 | unsigned int left; |
| 224 | unsigned int right; |
| 225 | unsigned int top; |
| 226 | unsigned int bottom; |
| 227 | } margins; |
| 228 | unsigned int mode; |
| 229 | unsigned int brightness; |
| 230 | unsigned int contrast; |
| 231 | unsigned int flicker_reduction; |
| 232 | unsigned int overscan; |
| 233 | unsigned int saturation; |
| 234 | unsigned int hue; |
| 235 | }; |
| 236 | |
| 237 | /** |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 238 | * struct drm_connector_state - mutable connector state |
| 239 | * @connector: backpointer to the connector |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 240 | * @best_encoder: can be used by helpers and drivers to select the encoder |
| 241 | * @state: backpointer to global drm_atomic_state |
Boris Brezillon | 299a16b | 2016-12-02 14:48:09 +0100 | [diff] [blame] | 242 | * @tv: TV connector state |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 243 | */ |
| 244 | struct drm_connector_state { |
| 245 | struct drm_connector *connector; |
| 246 | |
Daniel Vetter | afb21ea6 | 2016-08-31 18:09:04 +0200 | [diff] [blame] | 247 | /** |
| 248 | * @crtc: CRTC to connect connector to, NULL if disabled. |
| 249 | * |
| 250 | * Do not change this directly, use drm_atomic_set_crtc_for_connector() |
| 251 | * instead. |
| 252 | */ |
| 253 | struct drm_crtc *crtc; |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 254 | |
| 255 | struct drm_encoder *best_encoder; |
| 256 | |
Manasi Navare | 40ee6fb | 2016-12-16 12:29:06 +0200 | [diff] [blame] | 257 | /** |
| 258 | * @link_status: Connector link_status to keep track of whether link is |
| 259 | * GOOD or BAD to notify userspace if retraining is necessary. |
| 260 | */ |
| 261 | enum drm_link_status link_status; |
| 262 | |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 263 | struct drm_atomic_state *state; |
Boris Brezillon | 299a16b | 2016-12-02 14:48:09 +0100 | [diff] [blame] | 264 | |
| 265 | struct drm_tv_connector_state tv; |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 266 | }; |
| 267 | |
| 268 | /** |
| 269 | * struct drm_connector_funcs - control connectors on a given device |
| 270 | * |
| 271 | * Each CRTC may have one or more connectors attached to it. The functions |
| 272 | * below allow the core DRM code to control connectors, enumerate available modes, |
| 273 | * etc. |
| 274 | */ |
| 275 | struct drm_connector_funcs { |
| 276 | /** |
| 277 | * @dpms: |
| 278 | * |
| 279 | * Legacy entry point to set the per-connector DPMS state. Legacy DPMS |
| 280 | * is exposed as a standard property on the connector, but diverted to |
| 281 | * this callback in the drm core. Note that atomic drivers don't |
| 282 | * implement the 4 level DPMS support on the connector any more, but |
| 283 | * instead only have an on/off "ACTIVE" property on the CRTC object. |
| 284 | * |
| 285 | * Drivers implementing atomic modeset should use |
| 286 | * drm_atomic_helper_connector_dpms() to implement this hook. |
| 287 | * |
| 288 | * RETURNS: |
| 289 | * |
| 290 | * 0 on success or a negative error code on failure. |
| 291 | */ |
| 292 | int (*dpms)(struct drm_connector *connector, int mode); |
| 293 | |
| 294 | /** |
| 295 | * @reset: |
| 296 | * |
| 297 | * Reset connector hardware and software state to off. This function isn't |
| 298 | * called by the core directly, only through drm_mode_config_reset(). |
| 299 | * It's not a helper hook only for historical reasons. |
| 300 | * |
| 301 | * Atomic drivers can use drm_atomic_helper_connector_reset() to reset |
| 302 | * atomic state using this hook. |
| 303 | */ |
| 304 | void (*reset)(struct drm_connector *connector); |
| 305 | |
| 306 | /** |
| 307 | * @detect: |
| 308 | * |
| 309 | * Check to see if anything is attached to the connector. The parameter |
| 310 | * force is set to false whilst polling, true when checking the |
| 311 | * connector due to a user request. force can be used by the driver to |
| 312 | * avoid expensive, destructive operations during automated probing. |
| 313 | * |
Laurent Pinchart | 949f088 | 2016-11-29 22:56:30 +0200 | [diff] [blame] | 314 | * This callback is optional, if not implemented the connector will be |
| 315 | * considered as always being attached. |
| 316 | * |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 317 | * FIXME: |
| 318 | * |
| 319 | * Note that this hook is only called by the probe helper. It's not in |
| 320 | * the helper library vtable purely for historical reasons. The only DRM |
| 321 | * core entry point to probe connector state is @fill_modes. |
| 322 | * |
| 323 | * RETURNS: |
| 324 | * |
| 325 | * drm_connector_status indicating the connector's status. |
| 326 | */ |
| 327 | enum drm_connector_status (*detect)(struct drm_connector *connector, |
| 328 | bool force); |
| 329 | |
| 330 | /** |
| 331 | * @force: |
| 332 | * |
| 333 | * This function is called to update internal encoder state when the |
| 334 | * connector is forced to a certain state by userspace, either through |
| 335 | * the sysfs interfaces or on the kernel cmdline. In that case the |
| 336 | * @detect callback isn't called. |
| 337 | * |
| 338 | * FIXME: |
| 339 | * |
| 340 | * Note that this hook is only called by the probe helper. It's not in |
| 341 | * the helper library vtable purely for historical reasons. The only DRM |
| 342 | * core entry point to probe connector state is @fill_modes. |
| 343 | */ |
| 344 | void (*force)(struct drm_connector *connector); |
| 345 | |
| 346 | /** |
| 347 | * @fill_modes: |
| 348 | * |
| 349 | * Entry point for output detection and basic mode validation. The |
| 350 | * driver should reprobe the output if needed (e.g. when hotplug |
Daniel Vetter | d574528 | 2017-01-25 07:26:45 +0100 | [diff] [blame] | 351 | * handling is unreliable), add all detected modes to &drm_connector.modes |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 352 | * and filter out any the device can't support in any configuration. It |
| 353 | * also needs to filter out any modes wider or higher than the |
| 354 | * parameters max_width and max_height indicate. |
| 355 | * |
| 356 | * The drivers must also prune any modes no longer valid from |
Daniel Vetter | d574528 | 2017-01-25 07:26:45 +0100 | [diff] [blame] | 357 | * &drm_connector.modes. Furthermore it must update |
| 358 | * &drm_connector.status and &drm_connector.edid. If no EDID has been |
| 359 | * received for this output connector->edid must be NULL. |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 360 | * |
| 361 | * Drivers using the probe helpers should use |
| 362 | * drm_helper_probe_single_connector_modes() or |
| 363 | * drm_helper_probe_single_connector_modes_nomerge() to implement this |
| 364 | * function. |
| 365 | * |
| 366 | * RETURNS: |
| 367 | * |
Daniel Vetter | d574528 | 2017-01-25 07:26:45 +0100 | [diff] [blame] | 368 | * The number of modes detected and filled into &drm_connector.modes. |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 369 | */ |
| 370 | int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height); |
| 371 | |
| 372 | /** |
| 373 | * @set_property: |
| 374 | * |
| 375 | * This is the legacy entry point to update a property attached to the |
| 376 | * connector. |
| 377 | * |
| 378 | * Drivers implementing atomic modeset should use |
| 379 | * drm_atomic_helper_connector_set_property() to implement this hook. |
| 380 | * |
| 381 | * This callback is optional if the driver does not support any legacy |
| 382 | * driver-private properties. |
| 383 | * |
| 384 | * RETURNS: |
| 385 | * |
| 386 | * 0 on success or a negative error code on failure. |
| 387 | */ |
| 388 | int (*set_property)(struct drm_connector *connector, struct drm_property *property, |
| 389 | uint64_t val); |
| 390 | |
| 391 | /** |
| 392 | * @late_register: |
| 393 | * |
| 394 | * This optional hook can be used to register additional userspace |
| 395 | * interfaces attached to the connector, light backlight control, i2c, |
| 396 | * DP aux or similar interfaces. It is called late in the driver load |
| 397 | * sequence from drm_connector_register() when registering all the |
| 398 | * core drm connector interfaces. Everything added from this callback |
| 399 | * should be unregistered in the early_unregister callback. |
| 400 | * |
Daniel Vetter | d574528 | 2017-01-25 07:26:45 +0100 | [diff] [blame] | 401 | * This is called while holding &drm_connector.mutex. |
Daniel Vetter | e73ab00 | 2016-12-18 14:35:45 +0100 | [diff] [blame] | 402 | * |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 403 | * Returns: |
| 404 | * |
| 405 | * 0 on success, or a negative error code on failure. |
| 406 | */ |
| 407 | int (*late_register)(struct drm_connector *connector); |
| 408 | |
| 409 | /** |
| 410 | * @early_unregister: |
| 411 | * |
| 412 | * This optional hook should be used to unregister the additional |
| 413 | * userspace interfaces attached to the connector from |
Grazvydas Ignotas | 621a999 | 2016-10-09 20:07:00 +0300 | [diff] [blame] | 414 | * late_register(). It is called from drm_connector_unregister(), |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 415 | * early in the driver unload sequence to disable userspace access |
| 416 | * before data structures are torndown. |
Daniel Vetter | e73ab00 | 2016-12-18 14:35:45 +0100 | [diff] [blame] | 417 | * |
Daniel Vetter | d574528 | 2017-01-25 07:26:45 +0100 | [diff] [blame] | 418 | * This is called while holding &drm_connector.mutex. |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 419 | */ |
| 420 | void (*early_unregister)(struct drm_connector *connector); |
| 421 | |
| 422 | /** |
| 423 | * @destroy: |
| 424 | * |
| 425 | * Clean up connector resources. This is called at driver unload time |
| 426 | * through drm_mode_config_cleanup(). It can also be called at runtime |
| 427 | * when a connector is being hot-unplugged for drivers that support |
| 428 | * connector hotplugging (e.g. DisplayPort MST). |
| 429 | */ |
| 430 | void (*destroy)(struct drm_connector *connector); |
| 431 | |
| 432 | /** |
| 433 | * @atomic_duplicate_state: |
| 434 | * |
| 435 | * Duplicate the current atomic state for this connector and return it. |
Grazvydas Ignotas | 621a999 | 2016-10-09 20:07:00 +0300 | [diff] [blame] | 436 | * The core and helpers guarantee that any atomic state duplicated with |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 437 | * this hook and still owned by the caller (i.e. not transferred to the |
Daniel Vetter | d574528 | 2017-01-25 07:26:45 +0100 | [diff] [blame] | 438 | * driver by calling &drm_mode_config_funcs.atomic_commit) will be |
| 439 | * cleaned up by calling the @atomic_destroy_state hook in this |
| 440 | * structure. |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 441 | * |
Daniel Vetter | ea0dd85 | 2016-12-29 21:48:26 +0100 | [diff] [blame] | 442 | * Atomic drivers which don't subclass &struct drm_connector_state should use |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 443 | * drm_atomic_helper_connector_duplicate_state(). Drivers that subclass the |
| 444 | * state structure to extend it with driver-private state should use |
| 445 | * __drm_atomic_helper_connector_duplicate_state() to make sure shared state is |
| 446 | * duplicated in a consistent fashion across drivers. |
| 447 | * |
Daniel Vetter | d574528 | 2017-01-25 07:26:45 +0100 | [diff] [blame] | 448 | * It is an error to call this hook before &drm_connector.state has been |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 449 | * initialized correctly. |
| 450 | * |
| 451 | * NOTE: |
| 452 | * |
| 453 | * If the duplicate state references refcounted resources this hook must |
| 454 | * acquire a reference for each of them. The driver must release these |
| 455 | * references again in @atomic_destroy_state. |
| 456 | * |
| 457 | * RETURNS: |
| 458 | * |
| 459 | * Duplicated atomic state or NULL when the allocation failed. |
| 460 | */ |
| 461 | struct drm_connector_state *(*atomic_duplicate_state)(struct drm_connector *connector); |
| 462 | |
| 463 | /** |
| 464 | * @atomic_destroy_state: |
| 465 | * |
| 466 | * Destroy a state duplicated with @atomic_duplicate_state and release |
| 467 | * or unreference all resources it references |
| 468 | */ |
| 469 | void (*atomic_destroy_state)(struct drm_connector *connector, |
| 470 | struct drm_connector_state *state); |
| 471 | |
| 472 | /** |
| 473 | * @atomic_set_property: |
| 474 | * |
| 475 | * Decode a driver-private property value and store the decoded value |
| 476 | * into the passed-in state structure. Since the atomic core decodes all |
| 477 | * standardized properties (even for extensions beyond the core set of |
| 478 | * properties which might not be implemented by all drivers) this |
| 479 | * requires drivers to subclass the state structure. |
| 480 | * |
| 481 | * Such driver-private properties should really only be implemented for |
| 482 | * truly hardware/vendor specific state. Instead it is preferred to |
| 483 | * standardize atomic extension and decode the properties used to expose |
| 484 | * such an extension in the core. |
| 485 | * |
| 486 | * Do not call this function directly, use |
| 487 | * drm_atomic_connector_set_property() instead. |
| 488 | * |
| 489 | * This callback is optional if the driver does not support any |
| 490 | * driver-private atomic properties. |
| 491 | * |
| 492 | * NOTE: |
| 493 | * |
| 494 | * This function is called in the state assembly phase of atomic |
| 495 | * modesets, which can be aborted for any reason (including on |
| 496 | * userspace's request to just check whether a configuration would be |
| 497 | * possible). Drivers MUST NOT touch any persistent state (hardware or |
| 498 | * software) or data structures except the passed in @state parameter. |
| 499 | * |
| 500 | * Also since userspace controls in which order properties are set this |
| 501 | * function must not do any input validation (since the state update is |
| 502 | * incomplete and hence likely inconsistent). Instead any such input |
| 503 | * validation must be done in the various atomic_check callbacks. |
| 504 | * |
| 505 | * RETURNS: |
| 506 | * |
| 507 | * 0 if the property has been found, -EINVAL if the property isn't |
| 508 | * implemented by the driver (which shouldn't ever happen, the core only |
| 509 | * asks for properties attached to this connector). No other validation |
| 510 | * is allowed by the driver. The core already checks that the property |
| 511 | * value is within the range (integer, valid enum value, ...) the driver |
| 512 | * set when registering the property. |
| 513 | */ |
| 514 | int (*atomic_set_property)(struct drm_connector *connector, |
| 515 | struct drm_connector_state *state, |
| 516 | struct drm_property *property, |
| 517 | uint64_t val); |
| 518 | |
| 519 | /** |
| 520 | * @atomic_get_property: |
| 521 | * |
| 522 | * Reads out the decoded driver-private property. This is used to |
| 523 | * implement the GETCONNECTOR IOCTL. |
| 524 | * |
| 525 | * Do not call this function directly, use |
| 526 | * drm_atomic_connector_get_property() instead. |
| 527 | * |
| 528 | * This callback is optional if the driver does not support any |
| 529 | * driver-private atomic properties. |
| 530 | * |
| 531 | * RETURNS: |
| 532 | * |
| 533 | * 0 on success, -EINVAL if the property isn't implemented by the |
| 534 | * driver (which shouldn't ever happen, the core only asks for |
| 535 | * properties attached to this connector). |
| 536 | */ |
| 537 | int (*atomic_get_property)(struct drm_connector *connector, |
| 538 | const struct drm_connector_state *state, |
| 539 | struct drm_property *property, |
| 540 | uint64_t *val); |
Rob Clark | fceffb32 | 2016-11-05 11:08:09 -0400 | [diff] [blame] | 541 | |
| 542 | /** |
| 543 | * @atomic_print_state: |
| 544 | * |
Daniel Vetter | ea0dd85 | 2016-12-29 21:48:26 +0100 | [diff] [blame] | 545 | * If driver subclasses &struct drm_connector_state, it should implement |
Rob Clark | fceffb32 | 2016-11-05 11:08:09 -0400 | [diff] [blame] | 546 | * this optional hook for printing additional driver specific state. |
| 547 | * |
| 548 | * Do not call this directly, use drm_atomic_connector_print_state() |
| 549 | * instead. |
| 550 | */ |
| 551 | void (*atomic_print_state)(struct drm_printer *p, |
| 552 | const struct drm_connector_state *state); |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 553 | }; |
| 554 | |
| 555 | /* mode specified on the command line */ |
| 556 | struct drm_cmdline_mode { |
| 557 | bool specified; |
| 558 | bool refresh_specified; |
| 559 | bool bpp_specified; |
| 560 | int xres, yres; |
| 561 | int bpp; |
| 562 | int refresh; |
| 563 | bool rb; |
| 564 | bool interlace; |
| 565 | bool cvt; |
| 566 | bool margins; |
| 567 | enum drm_connector_force force; |
| 568 | }; |
| 569 | |
| 570 | /** |
| 571 | * struct drm_connector - central DRM connector control structure |
| 572 | * @dev: parent DRM device |
| 573 | * @kdev: kernel device for sysfs attributes |
| 574 | * @attr: sysfs attributes |
| 575 | * @head: list management |
| 576 | * @base: base KMS object |
| 577 | * @name: human readable name, can be overwritten by the driver |
| 578 | * @connector_type: one of the DRM_MODE_CONNECTOR_<foo> types from drm_mode.h |
| 579 | * @connector_type_id: index into connector type enum |
| 580 | * @interlace_allowed: can this connector handle interlaced modes? |
| 581 | * @doublescan_allowed: can this connector handle doublescan? |
| 582 | * @stereo_allowed: can this connector handle stereo modes? |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 583 | * @funcs: connector control functions |
| 584 | * @edid_blob_ptr: DRM property containing EDID if present |
| 585 | * @properties: property tracking for this connector |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 586 | * @dpms: current dpms state |
| 587 | * @helper_private: mid-layer private data |
| 588 | * @cmdline_mode: mode line parsed from the kernel cmdline for this connector |
| 589 | * @force: a DRM_FORCE_<foo> state for forced mode sets |
| 590 | * @override_edid: has the EDID been overwritten through debugfs for testing? |
| 591 | * @encoder_ids: valid encoders for this connector |
| 592 | * @encoder: encoder driving this connector, if any |
| 593 | * @eld: EDID-like data, if present |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 594 | * @latency_present: AV delay info from ELD, if found |
| 595 | * @video_latency: video latency info from ELD, if found |
| 596 | * @audio_latency: audio latency info from ELD, if found |
| 597 | * @null_edid_counter: track sinks that give us all zeros for the EDID |
| 598 | * @bad_edid_counter: track sinks that give us an EDID with invalid checksum |
| 599 | * @edid_corrupt: indicates whether the last read EDID was corrupt |
| 600 | * @debugfs_entry: debugfs directory for this connector |
| 601 | * @state: current atomic state for this connector |
| 602 | * @has_tile: is this connector connected to a tiled monitor |
| 603 | * @tile_group: tile group for the connected monitor |
| 604 | * @tile_is_single_monitor: whether the tile is one monitor housing |
| 605 | * @num_h_tile: number of horizontal tiles in the tile group |
| 606 | * @num_v_tile: number of vertical tiles in the tile group |
| 607 | * @tile_h_loc: horizontal location of this tile |
| 608 | * @tile_v_loc: vertical location of this tile |
| 609 | * @tile_h_size: horizontal size of this tile. |
| 610 | * @tile_v_size: vertical size of this tile. |
| 611 | * |
| 612 | * Each connector may be connected to one or more CRTCs, or may be clonable by |
| 613 | * another connector if they can share a CRTC. Each connector also has a specific |
| 614 | * position in the broader display (referred to as a 'screen' though it could |
| 615 | * span multiple monitors). |
| 616 | */ |
| 617 | struct drm_connector { |
| 618 | struct drm_device *dev; |
| 619 | struct device *kdev; |
| 620 | struct device_attribute *attr; |
| 621 | struct list_head head; |
| 622 | |
| 623 | struct drm_mode_object base; |
| 624 | |
| 625 | char *name; |
| 626 | |
| 627 | /** |
Daniel Vetter | e73ab00 | 2016-12-18 14:35:45 +0100 | [diff] [blame] | 628 | * @mutex: Lock for general connector state, but currently only protects |
Daniel Vetter | d574528 | 2017-01-25 07:26:45 +0100 | [diff] [blame] | 629 | * @registered. Most of the connector state is still protected by |
| 630 | * &drm_mode_config.mutex. |
Daniel Vetter | e73ab00 | 2016-12-18 14:35:45 +0100 | [diff] [blame] | 631 | */ |
| 632 | struct mutex mutex; |
| 633 | |
| 634 | /** |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 635 | * @index: Compacted connector index, which matches the position inside |
| 636 | * the mode_config.list for drivers not supporting hot-add/removing. Can |
| 637 | * be used as an array index. It is invariant over the lifetime of the |
| 638 | * connector. |
| 639 | */ |
| 640 | unsigned index; |
| 641 | |
| 642 | int connector_type; |
| 643 | int connector_type_id; |
| 644 | bool interlace_allowed; |
| 645 | bool doublescan_allowed; |
| 646 | bool stereo_allowed; |
Daniel Vetter | e73ab00 | 2016-12-18 14:35:45 +0100 | [diff] [blame] | 647 | /** |
| 648 | * @registered: Is this connector exposed (registered) with userspace? |
| 649 | * Protected by @mutex. |
| 650 | */ |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 651 | bool registered; |
Daniel Vetter | 91eefc0 | 2016-12-14 00:08:10 +0100 | [diff] [blame] | 652 | |
| 653 | /** |
| 654 | * @modes: |
| 655 | * Modes available on this connector (from fill_modes() + user). |
Daniel Vetter | d574528 | 2017-01-25 07:26:45 +0100 | [diff] [blame] | 656 | * Protected by &drm_mode_config.mutex. |
Daniel Vetter | 91eefc0 | 2016-12-14 00:08:10 +0100 | [diff] [blame] | 657 | */ |
Daniel Vetter | d574528 | 2017-01-25 07:26:45 +0100 | [diff] [blame] | 658 | struct list_head modes; |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 659 | |
Daniel Vetter | 91eefc0 | 2016-12-14 00:08:10 +0100 | [diff] [blame] | 660 | /** |
| 661 | * @status: |
| 662 | * One of the drm_connector_status enums (connected, not, or unknown). |
Daniel Vetter | d574528 | 2017-01-25 07:26:45 +0100 | [diff] [blame] | 663 | * Protected by &drm_mode_config.mutex. |
Daniel Vetter | 91eefc0 | 2016-12-14 00:08:10 +0100 | [diff] [blame] | 664 | */ |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 665 | enum drm_connector_status status; |
| 666 | |
Daniel Vetter | 91eefc0 | 2016-12-14 00:08:10 +0100 | [diff] [blame] | 667 | /** |
| 668 | * @probed_modes: |
| 669 | * These are modes added by probing with DDC or the BIOS, before |
Daniel Vetter | d574528 | 2017-01-25 07:26:45 +0100 | [diff] [blame] | 670 | * filtering is applied. Used by the probe helpers. Protected by |
| 671 | * &drm_mode_config.mutex. |
Daniel Vetter | 91eefc0 | 2016-12-14 00:08:10 +0100 | [diff] [blame] | 672 | */ |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 673 | struct list_head probed_modes; |
| 674 | |
Daniel Vetter | ae2a6da | 2016-08-12 22:48:53 +0200 | [diff] [blame] | 675 | /** |
| 676 | * @display_info: Display information is filled from EDID information |
| 677 | * when a display is detected. For non hot-pluggable displays such as |
| 678 | * flat panels in embedded systems, the driver should initialize the |
Daniel Vetter | d574528 | 2017-01-25 07:26:45 +0100 | [diff] [blame] | 679 | * &drm_display_info.width_mm and &drm_display_info.height_mm fields |
| 680 | * with the physical size of the display. |
Daniel Vetter | 91eefc0 | 2016-12-14 00:08:10 +0100 | [diff] [blame] | 681 | * |
Daniel Vetter | d574528 | 2017-01-25 07:26:45 +0100 | [diff] [blame] | 682 | * Protected by &drm_mode_config.mutex. |
Daniel Vetter | ae2a6da | 2016-08-12 22:48:53 +0200 | [diff] [blame] | 683 | */ |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 684 | struct drm_display_info display_info; |
| 685 | const struct drm_connector_funcs *funcs; |
| 686 | |
| 687 | struct drm_property_blob *edid_blob_ptr; |
| 688 | struct drm_object_properties properties; |
| 689 | |
| 690 | /** |
| 691 | * @path_blob_ptr: |
| 692 | * |
| 693 | * DRM blob property data for the DP MST path property. |
| 694 | */ |
| 695 | struct drm_property_blob *path_blob_ptr; |
| 696 | |
| 697 | /** |
| 698 | * @tile_blob_ptr: |
| 699 | * |
| 700 | * DRM blob property data for the tile property (used mostly by DP MST). |
| 701 | * This is meant for screens which are driven through separate display |
| 702 | * pipelines represented by &drm_crtc, which might not be running with |
| 703 | * genlocked clocks. For tiled panels which are genlocked, like |
| 704 | * dual-link LVDS or dual-link DSI, the driver should try to not expose |
| 705 | * the tiling and virtualize both &drm_crtc and &drm_plane if needed. |
| 706 | */ |
| 707 | struct drm_property_blob *tile_blob_ptr; |
| 708 | |
| 709 | /* should we poll this connector for connects and disconnects */ |
| 710 | /* hot plug detectable */ |
| 711 | #define DRM_CONNECTOR_POLL_HPD (1 << 0) |
| 712 | /* poll for connections */ |
| 713 | #define DRM_CONNECTOR_POLL_CONNECT (1 << 1) |
| 714 | /* can cleanly poll for disconnections without flickering the screen */ |
| 715 | /* DACs should rarely do this without a lot of testing */ |
| 716 | #define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2) |
| 717 | |
Daniel Vetter | ae2a6da | 2016-08-12 22:48:53 +0200 | [diff] [blame] | 718 | /** |
| 719 | * @polled: |
| 720 | * |
| 721 | * Connector polling mode, a combination of |
| 722 | * |
| 723 | * DRM_CONNECTOR_POLL_HPD |
| 724 | * The connector generates hotplug events and doesn't need to be |
| 725 | * periodically polled. The CONNECT and DISCONNECT flags must not |
| 726 | * be set together with the HPD flag. |
| 727 | * |
| 728 | * DRM_CONNECTOR_POLL_CONNECT |
| 729 | * Periodically poll the connector for connection. |
| 730 | * |
| 731 | * DRM_CONNECTOR_POLL_DISCONNECT |
| 732 | * Periodically poll the connector for disconnection. |
| 733 | * |
| 734 | * Set to 0 for connectors that don't support connection status |
| 735 | * discovery. |
| 736 | */ |
| 737 | uint8_t polled; |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 738 | |
| 739 | /* requested DPMS state */ |
| 740 | int dpms; |
| 741 | |
| 742 | const struct drm_connector_helper_funcs *helper_private; |
| 743 | |
| 744 | /* forced on connector */ |
| 745 | struct drm_cmdline_mode cmdline_mode; |
| 746 | enum drm_connector_force force; |
| 747 | bool override_edid; |
| 748 | |
| 749 | #define DRM_CONNECTOR_MAX_ENCODER 3 |
| 750 | uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER]; |
| 751 | struct drm_encoder *encoder; /* currently active encoder */ |
| 752 | |
| 753 | #define MAX_ELD_BYTES 128 |
| 754 | /* EDID bits */ |
| 755 | uint8_t eld[MAX_ELD_BYTES]; |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 756 | bool latency_present[2]; |
| 757 | int video_latency[2]; /* [0]: progressive, [1]: interlaced */ |
| 758 | int audio_latency[2]; |
| 759 | int null_edid_counter; /* needed to workaround some HW bugs where we get all 0s */ |
| 760 | unsigned bad_edid_counter; |
| 761 | |
| 762 | /* Flag for raw EDID header corruption - used in Displayport |
| 763 | * compliance testing - * Displayport Link CTS Core 1.2 rev1.1 4.2.2.6 |
| 764 | */ |
| 765 | bool edid_corrupt; |
| 766 | |
| 767 | struct dentry *debugfs_entry; |
| 768 | |
| 769 | struct drm_connector_state *state; |
| 770 | |
| 771 | /* DisplayID bits */ |
| 772 | bool has_tile; |
| 773 | struct drm_tile_group *tile_group; |
| 774 | bool tile_is_single_monitor; |
| 775 | |
| 776 | uint8_t num_h_tile, num_v_tile; |
| 777 | uint8_t tile_h_loc, tile_v_loc; |
| 778 | uint16_t tile_h_size, tile_v_size; |
| 779 | }; |
| 780 | |
| 781 | #define obj_to_connector(x) container_of(x, struct drm_connector, base) |
| 782 | |
| 783 | int drm_connector_init(struct drm_device *dev, |
| 784 | struct drm_connector *connector, |
| 785 | const struct drm_connector_funcs *funcs, |
| 786 | int connector_type); |
| 787 | int drm_connector_register(struct drm_connector *connector); |
| 788 | void drm_connector_unregister(struct drm_connector *connector); |
| 789 | int drm_mode_connector_attach_encoder(struct drm_connector *connector, |
| 790 | struct drm_encoder *encoder); |
| 791 | |
| 792 | void drm_connector_cleanup(struct drm_connector *connector); |
| 793 | static inline unsigned drm_connector_index(struct drm_connector *connector) |
| 794 | { |
| 795 | return connector->index; |
| 796 | } |
| 797 | |
| 798 | /** |
| 799 | * drm_connector_lookup - lookup connector object |
| 800 | * @dev: DRM device |
| 801 | * @id: connector object id |
| 802 | * |
| 803 | * This function looks up the connector object specified by id |
| 804 | * add takes a reference to it. |
| 805 | */ |
| 806 | static inline struct drm_connector *drm_connector_lookup(struct drm_device *dev, |
| 807 | uint32_t id) |
| 808 | { |
| 809 | struct drm_mode_object *mo; |
| 810 | mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CONNECTOR); |
| 811 | return mo ? obj_to_connector(mo) : NULL; |
| 812 | } |
| 813 | |
| 814 | /** |
Thierry Reding | ad09360 | 2017-02-28 15:46:39 +0100 | [diff] [blame] | 815 | * drm_connector_get - acquire a connector reference |
| 816 | * @connector: DRM connector |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 817 | * |
| 818 | * This function increments the connector's refcount. |
| 819 | */ |
Thierry Reding | ad09360 | 2017-02-28 15:46:39 +0100 | [diff] [blame] | 820 | static inline void drm_connector_get(struct drm_connector *connector) |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 821 | { |
Thierry Reding | ad09360 | 2017-02-28 15:46:39 +0100 | [diff] [blame] | 822 | drm_mode_object_get(&connector->base); |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 823 | } |
| 824 | |
| 825 | /** |
Thierry Reding | ad09360 | 2017-02-28 15:46:39 +0100 | [diff] [blame] | 826 | * drm_connector_put - release a connector reference |
| 827 | * @connector: DRM connector |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 828 | * |
Thierry Reding | ad09360 | 2017-02-28 15:46:39 +0100 | [diff] [blame] | 829 | * This function decrements the connector's reference count and frees the |
| 830 | * object if the reference count drops to zero. |
| 831 | */ |
| 832 | static inline void drm_connector_put(struct drm_connector *connector) |
| 833 | { |
| 834 | drm_mode_object_put(&connector->base); |
| 835 | } |
| 836 | |
| 837 | /** |
| 838 | * drm_connector_reference - acquire a connector reference |
| 839 | * @connector: DRM connector |
| 840 | * |
| 841 | * This is a compatibility alias for drm_connector_get() and should not be |
| 842 | * used by new code. |
| 843 | */ |
| 844 | static inline void drm_connector_reference(struct drm_connector *connector) |
| 845 | { |
| 846 | drm_connector_get(connector); |
| 847 | } |
| 848 | |
| 849 | /** |
| 850 | * drm_connector_unreference - release a connector reference |
| 851 | * @connector: DRM connector |
| 852 | * |
| 853 | * This is a compatibility alias for drm_connector_put() and should not be |
| 854 | * used by new code. |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 855 | */ |
| 856 | static inline void drm_connector_unreference(struct drm_connector *connector) |
| 857 | { |
Thierry Reding | ad09360 | 2017-02-28 15:46:39 +0100 | [diff] [blame] | 858 | drm_connector_put(connector); |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 859 | } |
| 860 | |
| 861 | const char *drm_get_connector_status_name(enum drm_connector_status status); |
| 862 | const char *drm_get_subpixel_order_name(enum subpixel_order order); |
| 863 | const char *drm_get_dpms_name(int val); |
| 864 | const char *drm_get_dvi_i_subconnector_name(int val); |
| 865 | const char *drm_get_dvi_i_select_name(int val); |
| 866 | const char *drm_get_tv_subconnector_name(int val); |
| 867 | const char *drm_get_tv_select_name(int val); |
| 868 | |
| 869 | int drm_mode_create_dvi_i_properties(struct drm_device *dev); |
| 870 | int drm_mode_create_tv_properties(struct drm_device *dev, |
| 871 | unsigned int num_modes, |
| 872 | const char * const modes[]); |
| 873 | int drm_mode_create_scaling_mode_property(struct drm_device *dev); |
| 874 | int drm_mode_create_aspect_ratio_property(struct drm_device *dev); |
| 875 | int drm_mode_create_suggested_offset_properties(struct drm_device *dev); |
| 876 | |
| 877 | int drm_mode_connector_set_path_property(struct drm_connector *connector, |
| 878 | const char *path); |
| 879 | int drm_mode_connector_set_tile_property(struct drm_connector *connector); |
| 880 | int drm_mode_connector_update_edid_property(struct drm_connector *connector, |
| 881 | const struct edid *edid); |
Manasi Navare | 40ee6fb | 2016-12-16 12:29:06 +0200 | [diff] [blame] | 882 | void drm_mode_connector_set_link_status_property(struct drm_connector *connector, |
| 883 | uint64_t link_status); |
Daniel Vetter | afb21ea6 | 2016-08-31 18:09:04 +0200 | [diff] [blame] | 884 | |
| 885 | /** |
Daniel Vetter | 9498c19 | 2016-11-14 12:58:24 +0100 | [diff] [blame] | 886 | * struct drm_tile_group - Tile group metadata |
| 887 | * @refcount: reference count |
| 888 | * @dev: DRM device |
| 889 | * @id: tile group id exposed to userspace |
| 890 | * @group_data: Sink-private data identifying this group |
| 891 | * |
| 892 | * @group_data corresponds to displayid vend/prod/serial for external screens |
| 893 | * with an EDID. |
| 894 | */ |
| 895 | struct drm_tile_group { |
| 896 | struct kref refcount; |
| 897 | struct drm_device *dev; |
| 898 | int id; |
| 899 | u8 group_data[8]; |
| 900 | }; |
| 901 | |
| 902 | struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev, |
| 903 | char topology[8]); |
| 904 | struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev, |
| 905 | char topology[8]); |
| 906 | void drm_mode_put_tile_group(struct drm_device *dev, |
| 907 | struct drm_tile_group *tg); |
| 908 | |
| 909 | /** |
Daniel Vetter | afb21ea6 | 2016-08-31 18:09:04 +0200 | [diff] [blame] | 910 | * drm_for_each_connector - iterate over all connectors |
| 911 | * @connector: the loop cursor |
| 912 | * @dev: the DRM device |
| 913 | * |
| 914 | * Iterate over all connectors of @dev. |
Daniel Vetter | 613051d | 2016-12-14 00:08:06 +0100 | [diff] [blame] | 915 | * |
| 916 | * WARNING: |
| 917 | * |
| 918 | * This iterator is not safe against hotadd/removal of connectors and is |
| 919 | * deprecated. Use drm_for_each_connector_iter() instead. |
Daniel Vetter | afb21ea6 | 2016-08-31 18:09:04 +0200 | [diff] [blame] | 920 | */ |
| 921 | #define drm_for_each_connector(connector, dev) \ |
Daniel Vetter | 347e890 | 2016-12-29 21:48:27 +0100 | [diff] [blame] | 922 | list_for_each_entry(connector, &(dev)->mode_config.connector_list, head) |
Daniel Vetter | afb21ea6 | 2016-08-31 18:09:04 +0200 | [diff] [blame] | 923 | |
Daniel Vetter | 613051d | 2016-12-14 00:08:06 +0100 | [diff] [blame] | 924 | /** |
| 925 | * struct drm_connector_list_iter - connector_list iterator |
| 926 | * |
| 927 | * This iterator tracks state needed to be able to walk the connector_list |
| 928 | * within struct drm_mode_config. Only use together with |
Thierry Reding | b982dab | 2017-02-28 15:46:43 +0100 | [diff] [blame^] | 929 | * drm_connector_list_iter_begin(), drm_connector_list_iter_end() and |
Daniel Vetter | 613051d | 2016-12-14 00:08:06 +0100 | [diff] [blame] | 930 | * drm_connector_list_iter_next() respectively the convenience macro |
| 931 | * drm_for_each_connector_iter(). |
| 932 | */ |
| 933 | struct drm_connector_list_iter { |
| 934 | /* private: */ |
| 935 | struct drm_device *dev; |
| 936 | struct drm_connector *conn; |
| 937 | }; |
| 938 | |
Thierry Reding | b982dab | 2017-02-28 15:46:43 +0100 | [diff] [blame^] | 939 | void drm_connector_list_iter_begin(struct drm_device *dev, |
| 940 | struct drm_connector_list_iter *iter); |
Daniel Vetter | 613051d | 2016-12-14 00:08:06 +0100 | [diff] [blame] | 941 | struct drm_connector * |
| 942 | drm_connector_list_iter_next(struct drm_connector_list_iter *iter); |
Thierry Reding | b982dab | 2017-02-28 15:46:43 +0100 | [diff] [blame^] | 943 | void drm_connector_list_iter_end(struct drm_connector_list_iter *iter); |
Daniel Vetter | 613051d | 2016-12-14 00:08:06 +0100 | [diff] [blame] | 944 | |
| 945 | /** |
| 946 | * drm_for_each_connector_iter - connector_list iterator macro |
Daniel Vetter | ea0dd85 | 2016-12-29 21:48:26 +0100 | [diff] [blame] | 947 | * @connector: &struct drm_connector pointer used as cursor |
| 948 | * @iter: &struct drm_connector_list_iter |
Daniel Vetter | 613051d | 2016-12-14 00:08:06 +0100 | [diff] [blame] | 949 | * |
| 950 | * Note that @connector is only valid within the list body, if you want to use |
Thierry Reding | b982dab | 2017-02-28 15:46:43 +0100 | [diff] [blame^] | 951 | * @connector after calling drm_connector_list_iter_end() then you need to grab |
| 952 | * your own reference first using drm_connector_begin(). |
Daniel Vetter | 613051d | 2016-12-14 00:08:06 +0100 | [diff] [blame] | 953 | */ |
| 954 | #define drm_for_each_connector_iter(connector, iter) \ |
| 955 | while ((connector = drm_connector_list_iter_next(iter))) |
| 956 | |
Daniel Vetter | 5221719 | 2016-08-12 22:48:50 +0200 | [diff] [blame] | 957 | #endif |