blob: 675cc3f8cf85292ce19aadee37d32f1f143771d8 [file] [log] [blame]
Daniel Vetter52217192016-08-12 22:48:50 +02001/*
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>
Daniel Vetterea497bb2017-12-13 13:49:36 +010027#include <linux/llist.h>
Daniel Vetter52217192016-08-12 22:48:50 +020028#include <linux/ctype.h>
Maarten Lankhorst0e9f25d2017-05-01 15:37:53 +020029#include <linux/hdmi.h>
Daniel Vetter949619f2016-08-29 10:27:51 +020030#include <drm/drm_mode_object.h>
Daniel Vetter52217192016-08-12 22:48:50 +020031
Daniel Vetter199e4e92016-08-31 18:09:05 +020032#include <uapi/drm/drm_mode.h>
33
Daniel Vetter52217192016-08-12 22:48:50 +020034struct drm_connector_helper_funcs;
Maarten Lankhorst6c5ed5a2017-04-06 20:55:20 +020035struct drm_modeset_acquire_ctx;
Daniel Vetter52217192016-08-12 22:48:50 +020036struct drm_device;
37struct drm_crtc;
38struct drm_encoder;
39struct drm_property;
40struct drm_property_blob;
Rob Clarkfceffb322016-11-05 11:08:09 -040041struct drm_printer;
Daniel Vetter52217192016-08-12 22:48:50 +020042struct edid;
43
44enum drm_connector_force {
45 DRM_FORCE_UNSPECIFIED,
46 DRM_FORCE_OFF,
47 DRM_FORCE_ON, /* force on analog part normally */
48 DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */
49};
50
Daniel Vetterae2a6da2016-08-12 22:48:53 +020051/**
52 * enum drm_connector_status - status for a &drm_connector
53 *
54 * This enum is used to track the connector status. There are no separate
55 * #defines for the uapi!
56 */
Daniel Vetter52217192016-08-12 22:48:50 +020057enum drm_connector_status {
Daniel Vetterae2a6da2016-08-12 22:48:53 +020058 /**
59 * @connector_status_connected: The connector is definitely connected to
60 * a sink device, and can be enabled.
61 */
Daniel Vetter52217192016-08-12 22:48:50 +020062 connector_status_connected = 1,
Daniel Vetterae2a6da2016-08-12 22:48:53 +020063 /**
64 * @connector_status_disconnected: The connector isn't connected to a
65 * sink device which can be autodetect. For digital outputs like DP or
66 * HDMI (which can be realiable probed) this means there's really
67 * nothing there. It is driver-dependent whether a connector with this
68 * status can be lit up or not.
69 */
Daniel Vetter52217192016-08-12 22:48:50 +020070 connector_status_disconnected = 2,
Daniel Vetterae2a6da2016-08-12 22:48:53 +020071 /**
72 * @connector_status_unknown: The connector's status could not be
73 * reliably detected. This happens when probing would either cause
74 * flicker (like load-detection when the connector is in use), or when a
75 * hardware resource isn't available (like when load-detection needs a
76 * free CRTC). It should be possible to light up the connector with one
77 * of the listed fallback modes. For default configuration userspace
78 * should only try to light up connectors with unknown status when
79 * there's not connector with @connector_status_connected.
80 */
Daniel Vetter52217192016-08-12 22:48:50 +020081 connector_status_unknown = 3,
82};
83
84enum subpixel_order {
85 SubPixelUnknown = 0,
86 SubPixelHorizontalRGB,
87 SubPixelHorizontalBGR,
88 SubPixelVerticalRGB,
89 SubPixelVerticalBGR,
90 SubPixelNone,
Shashank Sharmaafa1c762017-03-13 16:54:01 +053091
92};
93
Shashank Sharma62c58af2017-03-13 16:54:02 +053094/**
95 * struct drm_scrambling: sink's scrambling support.
96 */
97struct drm_scrambling {
98 /**
99 * @supported: scrambling supported for rates > 340 Mhz.
100 */
101 bool supported;
102 /**
103 * @low_rates: scrambling supported for rates <= 340 Mhz.
104 */
105 bool low_rates;
106};
107
Shashank Sharmaafa1c762017-03-13 16:54:01 +0530108/*
109 * struct drm_scdc - Information about scdc capabilities of a HDMI 2.0 sink
110 *
111 * Provides SCDC register support and capabilities related information on a
112 * HDMI 2.0 sink. In case of a HDMI 1.4 sink, all parameter must be 0.
113 */
114struct drm_scdc {
115 /**
116 * @supported: status control & data channel present.
117 */
118 bool supported;
119 /**
120 * @read_request: sink is capable of generating scdc read request.
121 */
122 bool read_request;
Shashank Sharma62c58af2017-03-13 16:54:02 +0530123 /**
124 * @scrambling: sink's scrambling capabilities
125 */
126 struct drm_scrambling scrambling;
Shashank Sharmaafa1c762017-03-13 16:54:01 +0530127};
128
Shashank Sharma62c58af2017-03-13 16:54:02 +0530129
Shashank Sharmaafa1c762017-03-13 16:54:01 +0530130/**
131 * struct drm_hdmi_info - runtime information about the connected HDMI sink
132 *
133 * Describes if a given display supports advanced HDMI 2.0 features.
134 * This information is available in CEA-861-F extension blocks (like HF-VSDB).
135 */
136struct drm_hdmi_info {
Shashank Sharma86cc9212017-03-28 10:06:19 +0300137 /** @scdc: sink's scdc support and capabilities */
Shashank Sharmaafa1c762017-03-13 16:54:01 +0530138 struct drm_scdc scdc;
Shashank Sharmad8523152017-07-13 21:03:11 +0530139
140 /**
141 * @y420_vdb_modes: bitmap of modes which can support ycbcr420
142 * output only (not normal RGB/YCBCR444/422 outputs). There are total
143 * 107 VICs defined by CEA-861-F spec, so the size is 128 bits to map
144 * upto 128 VICs;
145 */
146 unsigned long y420_vdb_modes[BITS_TO_LONGS(128)];
Shashank Sharma832d4f22017-07-14 16:03:46 +0530147
148 /**
149 * @y420_cmdb_modes: bitmap of modes which can support ycbcr420
150 * output also, along with normal HDMI outputs. There are total 107
151 * VICs defined by CEA-861-F spec, so the size is 128 bits to map upto
152 * 128 VICs;
153 */
154 unsigned long y420_cmdb_modes[BITS_TO_LONGS(128)];
155
156 /** @y420_cmdb_map: bitmap of SVD index, to extraxt vcb modes */
157 u64 y420_cmdb_map;
Shashank Sharmae6a9a2c2017-07-13 21:03:13 +0530158
159 /** @y420_dc_modes: bitmap of deep color support index */
160 u8 y420_dc_modes;
Daniel Vetter52217192016-08-12 22:48:50 +0200161};
162
Daniel Vetterb3c6c8b2016-08-12 22:48:55 +0200163/**
Manasi Navare40ee6fb2016-12-16 12:29:06 +0200164 * enum drm_link_status - connector's link_status property value
165 *
166 * This enum is used as the connector's link status property value.
167 * It is set to the values defined in uapi.
Manasi Navare41232c12017-03-01 06:45:10 -0800168 *
169 * @DRM_LINK_STATUS_GOOD: DP Link is Good as a result of successful
170 * link training
171 * @DRM_LINK_STATUS_BAD: DP Link is BAD as a result of link training
172 * failure
Manasi Navare40ee6fb2016-12-16 12:29:06 +0200173 */
174enum drm_link_status {
175 DRM_LINK_STATUS_GOOD = DRM_MODE_LINK_STATUS_GOOD,
176 DRM_LINK_STATUS_BAD = DRM_MODE_LINK_STATUS_BAD,
177};
178
179/**
Hans de Goede8d70f3952017-11-25 20:35:49 +0100180 * enum drm_panel_orientation - panel_orientation info for &drm_display_info
181 *
182 * This enum is used to track the (LCD) panel orientation. There are no
183 * separate #defines for the uapi!
184 *
185 * @DRM_MODE_PANEL_ORIENTATION_UNKNOWN: The drm driver has not provided any
186 * panel orientation information (normal
187 * for non panels) in this case the "panel
188 * orientation" connector prop will not be
189 * attached.
190 * @DRM_MODE_PANEL_ORIENTATION_NORMAL: The top side of the panel matches the
191 * top side of the device's casing.
192 * @DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP: The top side of the panel matches the
193 * bottom side of the device's casing, iow
194 * the panel is mounted upside-down.
195 * @DRM_MODE_PANEL_ORIENTATION_LEFT_UP: The left side of the panel matches the
196 * top side of the device's casing.
197 * @DRM_MODE_PANEL_ORIENTATION_RIGHT_UP: The right side of the panel matches the
198 * top side of the device's casing.
199 */
200enum drm_panel_orientation {
201 DRM_MODE_PANEL_ORIENTATION_UNKNOWN = -1,
202 DRM_MODE_PANEL_ORIENTATION_NORMAL = 0,
203 DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP,
204 DRM_MODE_PANEL_ORIENTATION_LEFT_UP,
205 DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
206};
207
208/**
Daniel Vetterb3c6c8b2016-08-12 22:48:55 +0200209 * struct drm_display_info - runtime data about the connected sink
210 *
211 * Describes a given display (e.g. CRT or flat panel) and its limitations. For
212 * fixed display sinks like built-in panels there's not much difference between
Daniel Vetterea0dd852016-12-29 21:48:26 +0100213 * this and &struct drm_connector. But for sinks with a real cable this
Daniel Vetterb3c6c8b2016-08-12 22:48:55 +0200214 * structure is meant to describe all the things at the other end of the cable.
215 *
216 * For sinks which provide an EDID this can be filled out by calling
217 * drm_add_edid_modes().
Daniel Vetter52217192016-08-12 22:48:50 +0200218 */
219struct drm_display_info {
Daniel Vetterb3c6c8b2016-08-12 22:48:55 +0200220 /**
221 * @name: Name of the display.
222 */
Daniel Vetter52217192016-08-12 22:48:50 +0200223 char name[DRM_DISPLAY_INFO_LEN];
224
Daniel Vetterb3c6c8b2016-08-12 22:48:55 +0200225 /**
226 * @width_mm: Physical width in mm.
227 */
Daniel Vetter52217192016-08-12 22:48:50 +0200228 unsigned int width_mm;
Daniel Vetterb3c6c8b2016-08-12 22:48:55 +0200229 /**
230 * @height_mm: Physical height in mm.
231 */
Daniel Vetter52217192016-08-12 22:48:50 +0200232 unsigned int height_mm;
233
Daniel Vetterb3c6c8b2016-08-12 22:48:55 +0200234 /**
235 * @pixel_clock: Maximum pixel clock supported by the sink, in units of
Peter Meerwald-Stadler188f78822016-12-16 14:24:23 +0100236 * 100Hz. This mismatches the clock in &drm_display_mode (which is in
Daniel Vetterb3c6c8b2016-08-12 22:48:55 +0200237 * kHZ), because that's what the EDID uses as base unit.
238 */
Daniel Vetter52217192016-08-12 22:48:50 +0200239 unsigned int pixel_clock;
Daniel Vetterb3c6c8b2016-08-12 22:48:55 +0200240 /**
241 * @bpc: Maximum bits per color channel. Used by HDMI and DP outputs.
242 */
Daniel Vetter52217192016-08-12 22:48:50 +0200243 unsigned int bpc;
244
Daniel Vetterb3c6c8b2016-08-12 22:48:55 +0200245 /**
246 * @subpixel_order: Subpixel order of LCD panels.
247 */
Daniel Vetter52217192016-08-12 22:48:50 +0200248 enum subpixel_order subpixel_order;
249
250#define DRM_COLOR_FORMAT_RGB444 (1<<0)
251#define DRM_COLOR_FORMAT_YCRCB444 (1<<1)
252#define DRM_COLOR_FORMAT_YCRCB422 (1<<2)
Shashank Sharma832d4f22017-07-14 16:03:46 +0530253#define DRM_COLOR_FORMAT_YCRCB420 (1<<3)
Daniel Vetter52217192016-08-12 22:48:50 +0200254
Daniel Vetterb3c6c8b2016-08-12 22:48:55 +0200255 /**
Hans de Goede8d70f3952017-11-25 20:35:49 +0100256 * @panel_orientation: Read only connector property for built-in panels,
257 * indicating the orientation of the panel vs the device's casing.
258 * drm_connector_init() sets this to DRM_MODE_PANEL_ORIENTATION_UNKNOWN.
259 * When not UNKNOWN this gets used by the drm_fb_helpers to rotate the
260 * fb to compensate and gets exported as prop to userspace.
261 */
262 int panel_orientation;
263
264 /**
Daniel Vetterb3c6c8b2016-08-12 22:48:55 +0200265 * @color_formats: HDMI Color formats, selects between RGB and YCrCb
266 * modes. Used DRM_COLOR_FORMAT\_ defines, which are _not_ the same ones
267 * as used to describe the pixel format in framebuffers, and also don't
268 * match the formats in @bus_formats which are shared with v4l.
269 */
Daniel Vetter52217192016-08-12 22:48:50 +0200270 u32 color_formats;
271
Daniel Vetterb3c6c8b2016-08-12 22:48:55 +0200272 /**
273 * @bus_formats: Pixel data format on the wire, somewhat redundant with
274 * @color_formats. Array of size @num_bus_formats encoded using
275 * MEDIA_BUS_FMT\_ defines shared with v4l and media drivers.
276 */
Daniel Vetter52217192016-08-12 22:48:50 +0200277 const u32 *bus_formats;
Daniel Vetterb3c6c8b2016-08-12 22:48:55 +0200278 /**
279 * @num_bus_formats: Size of @bus_formats array.
280 */
Daniel Vetter52217192016-08-12 22:48:50 +0200281 unsigned int num_bus_formats;
282
283#define DRM_BUS_FLAG_DE_LOW (1<<0)
284#define DRM_BUS_FLAG_DE_HIGH (1<<1)
285/* drive data on pos. edge */
286#define DRM_BUS_FLAG_PIXDATA_POSEDGE (1<<2)
287/* drive data on neg. edge */
288#define DRM_BUS_FLAG_PIXDATA_NEGEDGE (1<<3)
Laurent Pinchart5ec1a962016-11-18 16:55:48 +0200289/* data is transmitted MSB to LSB on the bus */
290#define DRM_BUS_FLAG_DATA_MSB_TO_LSB (1<<4)
291/* data is transmitted LSB to MSB on the bus */
292#define DRM_BUS_FLAG_DATA_LSB_TO_MSB (1<<5)
Daniel Vetter52217192016-08-12 22:48:50 +0200293
Daniel Vetterb3c6c8b2016-08-12 22:48:55 +0200294 /**
295 * @bus_flags: Additional information (like pixel signal polarity) for
296 * the pixel data on the bus, using DRM_BUS_FLAGS\_ defines.
297 */
Daniel Vetter52217192016-08-12 22:48:50 +0200298 u32 bus_flags;
299
Daniel Vetterb3c6c8b2016-08-12 22:48:55 +0200300 /**
Ville Syrjälä2a272ca2016-09-28 16:51:37 +0300301 * @max_tmds_clock: Maximum TMDS clock rate supported by the
302 * sink in kHz. 0 means undefined.
303 */
304 int max_tmds_clock;
305
306 /**
307 * @dvi_dual: Dual-link DVI sink?
308 */
309 bool dvi_dual;
310
311 /**
Ville Syrjäläf1781e92017-11-13 19:04:19 +0200312 * @has_hdmi_infoframe: Does the sink support the HDMI infoframe?
313 */
314 bool has_hdmi_infoframe;
315
316 /**
Daniel Vetterb3c6c8b2016-08-12 22:48:55 +0200317 * @edid_hdmi_dc_modes: Mask of supported hdmi deep color modes. Even
318 * more stuff redundant with @bus_formats.
319 */
Daniel Vetter52217192016-08-12 22:48:50 +0200320 u8 edid_hdmi_dc_modes;
321
Daniel Vetterb3c6c8b2016-08-12 22:48:55 +0200322 /**
323 * @cea_rev: CEA revision of the HDMI sink.
324 */
Daniel Vetter52217192016-08-12 22:48:50 +0200325 u8 cea_rev;
Shashank Sharmaafa1c762017-03-13 16:54:01 +0530326
327 /**
328 * @hdmi: advance features of a HDMI sink.
329 */
330 struct drm_hdmi_info hdmi;
Dave Airlie66660d42017-10-16 05:08:09 +0100331
332 /**
333 * @non_desktop: Non desktop display (HMD).
334 */
335 bool non_desktop;
Daniel Vetter52217192016-08-12 22:48:50 +0200336};
337
Daniel Vetterb3c6c8b2016-08-12 22:48:55 +0200338int drm_display_info_set_bus_formats(struct drm_display_info *info,
339 const u32 *formats,
340 unsigned int num_formats);
341
Daniel Vetter52217192016-08-12 22:48:50 +0200342/**
Boris Brezillon299a16b2016-12-02 14:48:09 +0100343 * struct drm_tv_connector_state - TV connector related states
344 * @subconnector: selected subconnector
Jani Nikula07d85292018-02-19 12:40:09 +0200345 * @margins: margins
346 * @margins.left: left margin
347 * @margins.right: right margin
348 * @margins.top: top margin
349 * @margins.bottom: bottom margin
Boris Brezillon299a16b2016-12-02 14:48:09 +0100350 * @mode: TV mode
351 * @brightness: brightness in percent
352 * @contrast: contrast in percent
353 * @flicker_reduction: flicker reduction in percent
354 * @overscan: overscan in percent
355 * @saturation: saturation in percent
356 * @hue: hue in percent
357 */
358struct drm_tv_connector_state {
359 enum drm_mode_subconnector subconnector;
360 struct {
361 unsigned int left;
362 unsigned int right;
363 unsigned int top;
364 unsigned int bottom;
365 } margins;
366 unsigned int mode;
367 unsigned int brightness;
368 unsigned int contrast;
369 unsigned int flicker_reduction;
370 unsigned int overscan;
371 unsigned int saturation;
372 unsigned int hue;
373};
374
375/**
Daniel Vetter52217192016-08-12 22:48:50 +0200376 * struct drm_connector_state - mutable connector state
377 * @connector: backpointer to the connector
Daniel Vetter52217192016-08-12 22:48:50 +0200378 * @best_encoder: can be used by helpers and drivers to select the encoder
379 * @state: backpointer to global drm_atomic_state
Boris Brezillon299a16b2016-12-02 14:48:09 +0100380 * @tv: TV connector state
Daniel Vetter52217192016-08-12 22:48:50 +0200381 */
382struct drm_connector_state {
383 struct drm_connector *connector;
384
Daniel Vetterafb21ea62016-08-31 18:09:04 +0200385 /**
386 * @crtc: CRTC to connect connector to, NULL if disabled.
387 *
388 * Do not change this directly, use drm_atomic_set_crtc_for_connector()
389 * instead.
390 */
391 struct drm_crtc *crtc;
Daniel Vetter52217192016-08-12 22:48:50 +0200392
393 struct drm_encoder *best_encoder;
394
Manasi Navare40ee6fb2016-12-16 12:29:06 +0200395 /**
396 * @link_status: Connector link_status to keep track of whether link is
397 * GOOD or BAD to notify userspace if retraining is necessary.
398 */
399 enum drm_link_status link_status;
400
Daniel Vetter52217192016-08-12 22:48:50 +0200401 struct drm_atomic_state *state;
Boris Brezillon299a16b2016-12-02 14:48:09 +0100402
Maarten Lankhorst21a01ab2017-09-04 12:48:37 +0200403 /**
404 * @commit: Tracks the pending commit to prevent use-after-free conditions.
405 *
406 * Is only set when @crtc is NULL.
407 */
408 struct drm_crtc_commit *commit;
409
Boris Brezillon299a16b2016-12-02 14:48:09 +0100410 struct drm_tv_connector_state tv;
Maarten Lankhorst0e9f25d2017-05-01 15:37:53 +0200411
412 /**
413 * @picture_aspect_ratio: Connector property to control the
414 * HDMI infoframe aspect ratio setting.
415 *
Maarten Lankhorst8f6e1e22017-05-01 15:37:54 +0200416 * The %DRM_MODE_PICTURE_ASPECT_\* values much match the
Maarten Lankhorst0e9f25d2017-05-01 15:37:53 +0200417 * values for &enum hdmi_picture_aspect
418 */
419 enum hdmi_picture_aspect picture_aspect_ratio;
Maarten Lankhorst8f6e1e22017-05-01 15:37:54 +0200420
421 /**
422 * @scaling_mode: Connector property to control the
423 * upscaling, mostly used for built-in panels.
424 */
425 unsigned int scaling_mode;
Sean Paul24557862018-01-08 14:55:37 -0500426
427 /**
428 * @content_protection: Connector property to request content
429 * protection. This is most commonly used for HDCP.
430 */
431 unsigned int content_protection;
Daniel Vetter52217192016-08-12 22:48:50 +0200432};
433
434/**
435 * struct drm_connector_funcs - control connectors on a given device
436 *
437 * Each CRTC may have one or more connectors attached to it. The functions
438 * below allow the core DRM code to control connectors, enumerate available modes,
439 * etc.
440 */
441struct drm_connector_funcs {
442 /**
443 * @dpms:
444 *
445 * Legacy entry point to set the per-connector DPMS state. Legacy DPMS
446 * is exposed as a standard property on the connector, but diverted to
447 * this callback in the drm core. Note that atomic drivers don't
448 * implement the 4 level DPMS support on the connector any more, but
449 * instead only have an on/off "ACTIVE" property on the CRTC object.
450 *
Daniel Vetter144a7992017-07-25 14:02:04 +0200451 * This hook is not used by atomic drivers, remapping of the legacy DPMS
452 * property is entirely handled in the DRM core.
Daniel Vetter52217192016-08-12 22:48:50 +0200453 *
454 * RETURNS:
455 *
456 * 0 on success or a negative error code on failure.
457 */
458 int (*dpms)(struct drm_connector *connector, int mode);
459
460 /**
461 * @reset:
462 *
463 * Reset connector hardware and software state to off. This function isn't
464 * called by the core directly, only through drm_mode_config_reset().
465 * It's not a helper hook only for historical reasons.
466 *
467 * Atomic drivers can use drm_atomic_helper_connector_reset() to reset
468 * atomic state using this hook.
469 */
470 void (*reset)(struct drm_connector *connector);
471
472 /**
473 * @detect:
474 *
475 * Check to see if anything is attached to the connector. The parameter
476 * force is set to false whilst polling, true when checking the
477 * connector due to a user request. force can be used by the driver to
478 * avoid expensive, destructive operations during automated probing.
479 *
Laurent Pinchart949f0882016-11-29 22:56:30 +0200480 * This callback is optional, if not implemented the connector will be
481 * considered as always being attached.
482 *
Daniel Vetter52217192016-08-12 22:48:50 +0200483 * FIXME:
484 *
485 * Note that this hook is only called by the probe helper. It's not in
486 * the helper library vtable purely for historical reasons. The only DRM
487 * core entry point to probe connector state is @fill_modes.
488 *
Maarten Lankhorst6c5ed5a2017-04-06 20:55:20 +0200489 * Note that the helper library will already hold
490 * &drm_mode_config.connection_mutex. Drivers which need to grab additional
491 * locks to avoid races with concurrent modeset changes need to use
492 * &drm_connector_helper_funcs.detect_ctx instead.
493 *
Daniel Vetter52217192016-08-12 22:48:50 +0200494 * RETURNS:
495 *
496 * drm_connector_status indicating the connector's status.
497 */
498 enum drm_connector_status (*detect)(struct drm_connector *connector,
499 bool force);
500
501 /**
502 * @force:
503 *
504 * This function is called to update internal encoder state when the
505 * connector is forced to a certain state by userspace, either through
506 * the sysfs interfaces or on the kernel cmdline. In that case the
507 * @detect callback isn't called.
508 *
509 * FIXME:
510 *
511 * Note that this hook is only called by the probe helper. It's not in
512 * the helper library vtable purely for historical reasons. The only DRM
513 * core entry point to probe connector state is @fill_modes.
514 */
515 void (*force)(struct drm_connector *connector);
516
517 /**
518 * @fill_modes:
519 *
520 * Entry point for output detection and basic mode validation. The
521 * driver should reprobe the output if needed (e.g. when hotplug
Daniel Vetterd5745282017-01-25 07:26:45 +0100522 * handling is unreliable), add all detected modes to &drm_connector.modes
Daniel Vetter52217192016-08-12 22:48:50 +0200523 * and filter out any the device can't support in any configuration. It
524 * also needs to filter out any modes wider or higher than the
525 * parameters max_width and max_height indicate.
526 *
527 * The drivers must also prune any modes no longer valid from
Daniel Vetterd5745282017-01-25 07:26:45 +0100528 * &drm_connector.modes. Furthermore it must update
529 * &drm_connector.status and &drm_connector.edid. If no EDID has been
530 * received for this output connector->edid must be NULL.
Daniel Vetter52217192016-08-12 22:48:50 +0200531 *
532 * Drivers using the probe helpers should use
533 * drm_helper_probe_single_connector_modes() or
534 * drm_helper_probe_single_connector_modes_nomerge() to implement this
535 * function.
536 *
537 * RETURNS:
538 *
Daniel Vetterd5745282017-01-25 07:26:45 +0100539 * The number of modes detected and filled into &drm_connector.modes.
Daniel Vetter52217192016-08-12 22:48:50 +0200540 */
541 int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height);
542
543 /**
544 * @set_property:
545 *
546 * This is the legacy entry point to update a property attached to the
547 * connector.
548 *
Daniel Vetter52217192016-08-12 22:48:50 +0200549 * This callback is optional if the driver does not support any legacy
Daniel Vetter144a7992017-07-25 14:02:04 +0200550 * driver-private properties. For atomic drivers it is not used because
551 * property handling is done entirely in the DRM core.
Daniel Vetter52217192016-08-12 22:48:50 +0200552 *
553 * RETURNS:
554 *
555 * 0 on success or a negative error code on failure.
556 */
557 int (*set_property)(struct drm_connector *connector, struct drm_property *property,
558 uint64_t val);
559
560 /**
561 * @late_register:
562 *
563 * This optional hook can be used to register additional userspace
564 * interfaces attached to the connector, light backlight control, i2c,
565 * DP aux or similar interfaces. It is called late in the driver load
566 * sequence from drm_connector_register() when registering all the
567 * core drm connector interfaces. Everything added from this callback
568 * should be unregistered in the early_unregister callback.
569 *
Daniel Vetterd5745282017-01-25 07:26:45 +0100570 * This is called while holding &drm_connector.mutex.
Daniel Vettere73ab002016-12-18 14:35:45 +0100571 *
Daniel Vetter52217192016-08-12 22:48:50 +0200572 * Returns:
573 *
574 * 0 on success, or a negative error code on failure.
575 */
576 int (*late_register)(struct drm_connector *connector);
577
578 /**
579 * @early_unregister:
580 *
581 * This optional hook should be used to unregister the additional
582 * userspace interfaces attached to the connector from
Grazvydas Ignotas621a9992016-10-09 20:07:00 +0300583 * late_register(). It is called from drm_connector_unregister(),
Daniel Vetter52217192016-08-12 22:48:50 +0200584 * early in the driver unload sequence to disable userspace access
585 * before data structures are torndown.
Daniel Vettere73ab002016-12-18 14:35:45 +0100586 *
Daniel Vetterd5745282017-01-25 07:26:45 +0100587 * This is called while holding &drm_connector.mutex.
Daniel Vetter52217192016-08-12 22:48:50 +0200588 */
589 void (*early_unregister)(struct drm_connector *connector);
590
591 /**
592 * @destroy:
593 *
594 * Clean up connector resources. This is called at driver unload time
595 * through drm_mode_config_cleanup(). It can also be called at runtime
596 * when a connector is being hot-unplugged for drivers that support
597 * connector hotplugging (e.g. DisplayPort MST).
598 */
599 void (*destroy)(struct drm_connector *connector);
600
601 /**
602 * @atomic_duplicate_state:
603 *
604 * Duplicate the current atomic state for this connector and return it.
Grazvydas Ignotas621a9992016-10-09 20:07:00 +0300605 * The core and helpers guarantee that any atomic state duplicated with
Daniel Vetter52217192016-08-12 22:48:50 +0200606 * this hook and still owned by the caller (i.e. not transferred to the
Daniel Vetterd5745282017-01-25 07:26:45 +0100607 * driver by calling &drm_mode_config_funcs.atomic_commit) will be
608 * cleaned up by calling the @atomic_destroy_state hook in this
609 * structure.
Daniel Vetter52217192016-08-12 22:48:50 +0200610 *
Daniel Vetterea0dd852016-12-29 21:48:26 +0100611 * Atomic drivers which don't subclass &struct drm_connector_state should use
Daniel Vetter52217192016-08-12 22:48:50 +0200612 * drm_atomic_helper_connector_duplicate_state(). Drivers that subclass the
613 * state structure to extend it with driver-private state should use
614 * __drm_atomic_helper_connector_duplicate_state() to make sure shared state is
615 * duplicated in a consistent fashion across drivers.
616 *
Daniel Vetterd5745282017-01-25 07:26:45 +0100617 * It is an error to call this hook before &drm_connector.state has been
Daniel Vetter52217192016-08-12 22:48:50 +0200618 * initialized correctly.
619 *
620 * NOTE:
621 *
622 * If the duplicate state references refcounted resources this hook must
623 * acquire a reference for each of them. The driver must release these
624 * references again in @atomic_destroy_state.
625 *
626 * RETURNS:
627 *
628 * Duplicated atomic state or NULL when the allocation failed.
629 */
630 struct drm_connector_state *(*atomic_duplicate_state)(struct drm_connector *connector);
631
632 /**
633 * @atomic_destroy_state:
634 *
635 * Destroy a state duplicated with @atomic_duplicate_state and release
636 * or unreference all resources it references
637 */
638 void (*atomic_destroy_state)(struct drm_connector *connector,
639 struct drm_connector_state *state);
640
641 /**
642 * @atomic_set_property:
643 *
644 * Decode a driver-private property value and store the decoded value
645 * into the passed-in state structure. Since the atomic core decodes all
646 * standardized properties (even for extensions beyond the core set of
647 * properties which might not be implemented by all drivers) this
648 * requires drivers to subclass the state structure.
649 *
650 * Such driver-private properties should really only be implemented for
651 * truly hardware/vendor specific state. Instead it is preferred to
652 * standardize atomic extension and decode the properties used to expose
653 * such an extension in the core.
654 *
655 * Do not call this function directly, use
656 * drm_atomic_connector_set_property() instead.
657 *
658 * This callback is optional if the driver does not support any
659 * driver-private atomic properties.
660 *
661 * NOTE:
662 *
663 * This function is called in the state assembly phase of atomic
664 * modesets, which can be aborted for any reason (including on
665 * userspace's request to just check whether a configuration would be
666 * possible). Drivers MUST NOT touch any persistent state (hardware or
667 * software) or data structures except the passed in @state parameter.
668 *
669 * Also since userspace controls in which order properties are set this
670 * function must not do any input validation (since the state update is
671 * incomplete and hence likely inconsistent). Instead any such input
672 * validation must be done in the various atomic_check callbacks.
673 *
674 * RETURNS:
675 *
676 * 0 if the property has been found, -EINVAL if the property isn't
677 * implemented by the driver (which shouldn't ever happen, the core only
678 * asks for properties attached to this connector). No other validation
679 * is allowed by the driver. The core already checks that the property
680 * value is within the range (integer, valid enum value, ...) the driver
681 * set when registering the property.
682 */
683 int (*atomic_set_property)(struct drm_connector *connector,
684 struct drm_connector_state *state,
685 struct drm_property *property,
686 uint64_t val);
687
688 /**
689 * @atomic_get_property:
690 *
691 * Reads out the decoded driver-private property. This is used to
692 * implement the GETCONNECTOR IOCTL.
693 *
694 * Do not call this function directly, use
695 * drm_atomic_connector_get_property() instead.
696 *
697 * This callback is optional if the driver does not support any
698 * driver-private atomic properties.
699 *
700 * RETURNS:
701 *
702 * 0 on success, -EINVAL if the property isn't implemented by the
703 * driver (which shouldn't ever happen, the core only asks for
704 * properties attached to this connector).
705 */
706 int (*atomic_get_property)(struct drm_connector *connector,
707 const struct drm_connector_state *state,
708 struct drm_property *property,
709 uint64_t *val);
Rob Clarkfceffb322016-11-05 11:08:09 -0400710
711 /**
712 * @atomic_print_state:
713 *
Daniel Vetterea0dd852016-12-29 21:48:26 +0100714 * If driver subclasses &struct drm_connector_state, it should implement
Rob Clarkfceffb322016-11-05 11:08:09 -0400715 * this optional hook for printing additional driver specific state.
716 *
717 * Do not call this directly, use drm_atomic_connector_print_state()
718 * instead.
719 */
720 void (*atomic_print_state)(struct drm_printer *p,
721 const struct drm_connector_state *state);
Daniel Vetter52217192016-08-12 22:48:50 +0200722};
723
724/* mode specified on the command line */
725struct drm_cmdline_mode {
726 bool specified;
727 bool refresh_specified;
728 bool bpp_specified;
729 int xres, yres;
730 int bpp;
731 int refresh;
732 bool rb;
733 bool interlace;
734 bool cvt;
735 bool margins;
736 enum drm_connector_force force;
737};
738
739/**
740 * struct drm_connector - central DRM connector control structure
741 * @dev: parent DRM device
742 * @kdev: kernel device for sysfs attributes
743 * @attr: sysfs attributes
744 * @head: list management
745 * @base: base KMS object
746 * @name: human readable name, can be overwritten by the driver
747 * @connector_type: one of the DRM_MODE_CONNECTOR_<foo> types from drm_mode.h
748 * @connector_type_id: index into connector type enum
749 * @interlace_allowed: can this connector handle interlaced modes?
750 * @doublescan_allowed: can this connector handle doublescan?
751 * @stereo_allowed: can this connector handle stereo modes?
Daniel Vetter52217192016-08-12 22:48:50 +0200752 * @funcs: connector control functions
753 * @edid_blob_ptr: DRM property containing EDID if present
754 * @properties: property tracking for this connector
Daniel Vetter52217192016-08-12 22:48:50 +0200755 * @dpms: current dpms state
756 * @helper_private: mid-layer private data
757 * @cmdline_mode: mode line parsed from the kernel cmdline for this connector
758 * @force: a DRM_FORCE_<foo> state for forced mode sets
759 * @override_edid: has the EDID been overwritten through debugfs for testing?
760 * @encoder_ids: valid encoders for this connector
Daniel Vetter52217192016-08-12 22:48:50 +0200761 * @eld: EDID-like data, if present
Daniel Vetter52217192016-08-12 22:48:50 +0200762 * @latency_present: AV delay info from ELD, if found
763 * @video_latency: video latency info from ELD, if found
764 * @audio_latency: audio latency info from ELD, if found
765 * @null_edid_counter: track sinks that give us all zeros for the EDID
766 * @bad_edid_counter: track sinks that give us an EDID with invalid checksum
767 * @edid_corrupt: indicates whether the last read EDID was corrupt
768 * @debugfs_entry: debugfs directory for this connector
Daniel Vetter52217192016-08-12 22:48:50 +0200769 * @has_tile: is this connector connected to a tiled monitor
770 * @tile_group: tile group for the connected monitor
771 * @tile_is_single_monitor: whether the tile is one monitor housing
772 * @num_h_tile: number of horizontal tiles in the tile group
773 * @num_v_tile: number of vertical tiles in the tile group
774 * @tile_h_loc: horizontal location of this tile
775 * @tile_v_loc: vertical location of this tile
776 * @tile_h_size: horizontal size of this tile.
777 * @tile_v_size: vertical size of this tile.
Maarten Lankhorst8f6e1e22017-05-01 15:37:54 +0200778 * @scaling_mode_property: Optional atomic property to control the upscaling.
Sean Paul24557862018-01-08 14:55:37 -0500779 * @content_protection_property: Optional property to control content protection
Daniel Vetter52217192016-08-12 22:48:50 +0200780 *
781 * Each connector may be connected to one or more CRTCs, or may be clonable by
782 * another connector if they can share a CRTC. Each connector also has a specific
783 * position in the broader display (referred to as a 'screen' though it could
784 * span multiple monitors).
785 */
786struct drm_connector {
787 struct drm_device *dev;
788 struct device *kdev;
789 struct device_attribute *attr;
790 struct list_head head;
791
792 struct drm_mode_object base;
793
794 char *name;
795
796 /**
Daniel Vettere73ab002016-12-18 14:35:45 +0100797 * @mutex: Lock for general connector state, but currently only protects
Daniel Vetterd5745282017-01-25 07:26:45 +0100798 * @registered. Most of the connector state is still protected by
799 * &drm_mode_config.mutex.
Daniel Vettere73ab002016-12-18 14:35:45 +0100800 */
801 struct mutex mutex;
802
803 /**
Daniel Vetter52217192016-08-12 22:48:50 +0200804 * @index: Compacted connector index, which matches the position inside
805 * the mode_config.list for drivers not supporting hot-add/removing. Can
806 * be used as an array index. It is invariant over the lifetime of the
807 * connector.
808 */
809 unsigned index;
810
811 int connector_type;
812 int connector_type_id;
813 bool interlace_allowed;
814 bool doublescan_allowed;
815 bool stereo_allowed;
Shashank Sharmad8523152017-07-13 21:03:11 +0530816
817 /**
818 * @ycbcr_420_allowed : This bool indicates if this connector is
819 * capable of handling YCBCR 420 output. While parsing the EDID
820 * blocks, its very helpful to know, if the source is capable of
821 * handling YCBCR 420 outputs.
822 */
823 bool ycbcr_420_allowed;
824
Daniel Vettere73ab002016-12-18 14:35:45 +0100825 /**
826 * @registered: Is this connector exposed (registered) with userspace?
827 * Protected by @mutex.
828 */
Daniel Vetter52217192016-08-12 22:48:50 +0200829 bool registered;
Daniel Vetter91eefc02016-12-14 00:08:10 +0100830
831 /**
832 * @modes:
833 * Modes available on this connector (from fill_modes() + user).
Daniel Vetterd5745282017-01-25 07:26:45 +0100834 * Protected by &drm_mode_config.mutex.
Daniel Vetter91eefc02016-12-14 00:08:10 +0100835 */
Daniel Vetterd5745282017-01-25 07:26:45 +0100836 struct list_head modes;
Daniel Vetter52217192016-08-12 22:48:50 +0200837
Daniel Vetter91eefc02016-12-14 00:08:10 +0100838 /**
839 * @status:
840 * One of the drm_connector_status enums (connected, not, or unknown).
Daniel Vetterd5745282017-01-25 07:26:45 +0100841 * Protected by &drm_mode_config.mutex.
Daniel Vetter91eefc02016-12-14 00:08:10 +0100842 */
Daniel Vetter52217192016-08-12 22:48:50 +0200843 enum drm_connector_status status;
844
Daniel Vetter91eefc02016-12-14 00:08:10 +0100845 /**
846 * @probed_modes:
847 * These are modes added by probing with DDC or the BIOS, before
Daniel Vetterd5745282017-01-25 07:26:45 +0100848 * filtering is applied. Used by the probe helpers. Protected by
849 * &drm_mode_config.mutex.
Daniel Vetter91eefc02016-12-14 00:08:10 +0100850 */
Daniel Vetter52217192016-08-12 22:48:50 +0200851 struct list_head probed_modes;
852
Daniel Vetterae2a6da2016-08-12 22:48:53 +0200853 /**
854 * @display_info: Display information is filled from EDID information
855 * when a display is detected. For non hot-pluggable displays such as
856 * flat panels in embedded systems, the driver should initialize the
Daniel Vetterd5745282017-01-25 07:26:45 +0100857 * &drm_display_info.width_mm and &drm_display_info.height_mm fields
858 * with the physical size of the display.
Daniel Vetter91eefc02016-12-14 00:08:10 +0100859 *
Daniel Vetterd5745282017-01-25 07:26:45 +0100860 * Protected by &drm_mode_config.mutex.
Daniel Vetterae2a6da2016-08-12 22:48:53 +0200861 */
Daniel Vetter52217192016-08-12 22:48:50 +0200862 struct drm_display_info display_info;
863 const struct drm_connector_funcs *funcs;
864
865 struct drm_property_blob *edid_blob_ptr;
866 struct drm_object_properties properties;
867
Maarten Lankhorst8f6e1e22017-05-01 15:37:54 +0200868 struct drm_property *scaling_mode_property;
869
Daniel Vetter52217192016-08-12 22:48:50 +0200870 /**
Sean Paul24557862018-01-08 14:55:37 -0500871 * @content_protection_property: DRM ENUM property for content
872 * protection
873 */
874 struct drm_property *content_protection_property;
875
876 /**
Daniel Vetter52217192016-08-12 22:48:50 +0200877 * @path_blob_ptr:
878 *
879 * DRM blob property data for the DP MST path property.
880 */
881 struct drm_property_blob *path_blob_ptr;
882
883 /**
884 * @tile_blob_ptr:
885 *
886 * DRM blob property data for the tile property (used mostly by DP MST).
887 * This is meant for screens which are driven through separate display
888 * pipelines represented by &drm_crtc, which might not be running with
889 * genlocked clocks. For tiled panels which are genlocked, like
890 * dual-link LVDS or dual-link DSI, the driver should try to not expose
891 * the tiling and virtualize both &drm_crtc and &drm_plane if needed.
892 */
893 struct drm_property_blob *tile_blob_ptr;
894
895/* should we poll this connector for connects and disconnects */
896/* hot plug detectable */
897#define DRM_CONNECTOR_POLL_HPD (1 << 0)
898/* poll for connections */
899#define DRM_CONNECTOR_POLL_CONNECT (1 << 1)
900/* can cleanly poll for disconnections without flickering the screen */
901/* DACs should rarely do this without a lot of testing */
902#define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2)
903
Daniel Vetterae2a6da2016-08-12 22:48:53 +0200904 /**
905 * @polled:
906 *
907 * Connector polling mode, a combination of
908 *
909 * DRM_CONNECTOR_POLL_HPD
910 * The connector generates hotplug events and doesn't need to be
911 * periodically polled. The CONNECT and DISCONNECT flags must not
912 * be set together with the HPD flag.
913 *
914 * DRM_CONNECTOR_POLL_CONNECT
915 * Periodically poll the connector for connection.
916 *
917 * DRM_CONNECTOR_POLL_DISCONNECT
918 * Periodically poll the connector for disconnection.
919 *
920 * Set to 0 for connectors that don't support connection status
921 * discovery.
922 */
923 uint8_t polled;
Daniel Vetter52217192016-08-12 22:48:50 +0200924
925 /* requested DPMS state */
926 int dpms;
927
928 const struct drm_connector_helper_funcs *helper_private;
929
930 /* forced on connector */
931 struct drm_cmdline_mode cmdline_mode;
932 enum drm_connector_force force;
933 bool override_edid;
934
935#define DRM_CONNECTOR_MAX_ENCODER 3
936 uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER];
Daniel Vetter2e2b96e2017-11-08 21:30:07 +0100937 /**
938 * @encoder: Currently bound encoder driving this connector, if any.
939 * Only really meaningful for non-atomic drivers. Atomic drivers should
940 * instead look at &drm_connector_state.best_encoder, and in case they
941 * need the CRTC driving this output, &drm_connector_state.crtc.
942 */
943 struct drm_encoder *encoder;
Daniel Vetter52217192016-08-12 22:48:50 +0200944
945#define MAX_ELD_BYTES 128
946 /* EDID bits */
947 uint8_t eld[MAX_ELD_BYTES];
Daniel Vetter52217192016-08-12 22:48:50 +0200948 bool latency_present[2];
949 int video_latency[2]; /* [0]: progressive, [1]: interlaced */
950 int audio_latency[2];
951 int null_edid_counter; /* needed to workaround some HW bugs where we get all 0s */
952 unsigned bad_edid_counter;
953
954 /* Flag for raw EDID header corruption - used in Displayport
955 * compliance testing - * Displayport Link CTS Core 1.2 rev1.1 4.2.2.6
956 */
957 bool edid_corrupt;
958
959 struct dentry *debugfs_entry;
960
Daniel Vetterc9e42b72017-03-28 17:53:48 +0200961 /**
962 * @state:
963 *
964 * Current atomic state for this connector.
965 *
966 * This is protected by @drm_mode_config.connection_mutex. Note that
967 * nonblocking atomic commits access the current connector state without
968 * taking locks. Either by going through the &struct drm_atomic_state
Maarten Lankhorst77ac3b02017-07-19 16:39:20 +0200969 * pointers, see for_each_oldnew_connector_in_state(),
Daniel Vetterc9e42b72017-03-28 17:53:48 +0200970 * for_each_old_connector_in_state() and
971 * for_each_new_connector_in_state(). Or through careful ordering of
972 * atomic commit operations as implemented in the atomic helpers, see
973 * &struct drm_crtc_commit.
974 */
Daniel Vetter52217192016-08-12 22:48:50 +0200975 struct drm_connector_state *state;
976
977 /* DisplayID bits */
978 bool has_tile;
979 struct drm_tile_group *tile_group;
980 bool tile_is_single_monitor;
981
982 uint8_t num_h_tile, num_v_tile;
983 uint8_t tile_h_loc, tile_v_loc;
984 uint16_t tile_h_size, tile_v_size;
Daniel Vettera703c552017-12-04 21:48:18 +0100985
986 /**
Daniel Vetterea497bb2017-12-13 13:49:36 +0100987 * @free_node:
Daniel Vettera703c552017-12-04 21:48:18 +0100988 *
Daniel Vetterea497bb2017-12-13 13:49:36 +0100989 * List used only by &drm_connector_iter to be able to clean up a
990 * connector from any context, in conjunction with
991 * &drm_mode_config.connector_free_work.
Daniel Vettera703c552017-12-04 21:48:18 +0100992 */
Daniel Vetterea497bb2017-12-13 13:49:36 +0100993 struct llist_node free_node;
Daniel Vetter52217192016-08-12 22:48:50 +0200994};
995
996#define obj_to_connector(x) container_of(x, struct drm_connector, base)
997
998int drm_connector_init(struct drm_device *dev,
999 struct drm_connector *connector,
1000 const struct drm_connector_funcs *funcs,
1001 int connector_type);
1002int drm_connector_register(struct drm_connector *connector);
1003void drm_connector_unregister(struct drm_connector *connector);
1004int drm_mode_connector_attach_encoder(struct drm_connector *connector,
1005 struct drm_encoder *encoder);
1006
1007void drm_connector_cleanup(struct drm_connector *connector);
1008static inline unsigned drm_connector_index(struct drm_connector *connector)
1009{
1010 return connector->index;
1011}
1012
1013/**
1014 * drm_connector_lookup - lookup connector object
1015 * @dev: DRM device
Dave Airliee7e62c72017-11-09 09:35:04 +10001016 * @file_priv: drm file to check for lease against.
Daniel Vetter52217192016-08-12 22:48:50 +02001017 * @id: connector object id
1018 *
1019 * This function looks up the connector object specified by id
1020 * add takes a reference to it.
1021 */
1022static inline struct drm_connector *drm_connector_lookup(struct drm_device *dev,
Keith Packard418da172017-03-14 23:25:07 -07001023 struct drm_file *file_priv,
Daniel Vetter52217192016-08-12 22:48:50 +02001024 uint32_t id)
1025{
1026 struct drm_mode_object *mo;
Keith Packard418da172017-03-14 23:25:07 -07001027 mo = drm_mode_object_find(dev, file_priv, id, DRM_MODE_OBJECT_CONNECTOR);
Daniel Vetter52217192016-08-12 22:48:50 +02001028 return mo ? obj_to_connector(mo) : NULL;
1029}
1030
1031/**
Thierry Redingad093602017-02-28 15:46:39 +01001032 * drm_connector_get - acquire a connector reference
1033 * @connector: DRM connector
Daniel Vetter52217192016-08-12 22:48:50 +02001034 *
1035 * This function increments the connector's refcount.
1036 */
Thierry Redingad093602017-02-28 15:46:39 +01001037static inline void drm_connector_get(struct drm_connector *connector)
Daniel Vetter52217192016-08-12 22:48:50 +02001038{
Thierry Redingad093602017-02-28 15:46:39 +01001039 drm_mode_object_get(&connector->base);
Daniel Vetter52217192016-08-12 22:48:50 +02001040}
1041
1042/**
Thierry Redingad093602017-02-28 15:46:39 +01001043 * drm_connector_put - release a connector reference
1044 * @connector: DRM connector
Daniel Vetter52217192016-08-12 22:48:50 +02001045 *
Thierry Redingad093602017-02-28 15:46:39 +01001046 * This function decrements the connector's reference count and frees the
1047 * object if the reference count drops to zero.
1048 */
1049static inline void drm_connector_put(struct drm_connector *connector)
1050{
1051 drm_mode_object_put(&connector->base);
1052}
1053
1054/**
1055 * drm_connector_reference - acquire a connector reference
1056 * @connector: DRM connector
1057 *
1058 * This is a compatibility alias for drm_connector_get() and should not be
1059 * used by new code.
1060 */
1061static inline void drm_connector_reference(struct drm_connector *connector)
1062{
1063 drm_connector_get(connector);
1064}
1065
1066/**
1067 * drm_connector_unreference - release a connector reference
1068 * @connector: DRM connector
1069 *
1070 * This is a compatibility alias for drm_connector_put() and should not be
1071 * used by new code.
Daniel Vetter52217192016-08-12 22:48:50 +02001072 */
1073static inline void drm_connector_unreference(struct drm_connector *connector)
1074{
Thierry Redingad093602017-02-28 15:46:39 +01001075 drm_connector_put(connector);
Daniel Vetter52217192016-08-12 22:48:50 +02001076}
1077
1078const char *drm_get_connector_status_name(enum drm_connector_status status);
1079const char *drm_get_subpixel_order_name(enum subpixel_order order);
1080const char *drm_get_dpms_name(int val);
1081const char *drm_get_dvi_i_subconnector_name(int val);
1082const char *drm_get_dvi_i_select_name(int val);
1083const char *drm_get_tv_subconnector_name(int val);
1084const char *drm_get_tv_select_name(int val);
Sean Paul24557862018-01-08 14:55:37 -05001085const char *drm_get_content_protection_name(int val);
Daniel Vetter52217192016-08-12 22:48:50 +02001086
1087int drm_mode_create_dvi_i_properties(struct drm_device *dev);
1088int drm_mode_create_tv_properties(struct drm_device *dev,
1089 unsigned int num_modes,
1090 const char * const modes[]);
1091int drm_mode_create_scaling_mode_property(struct drm_device *dev);
Maarten Lankhorst8f6e1e22017-05-01 15:37:54 +02001092int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,
1093 u32 scaling_mode_mask);
Sean Paul24557862018-01-08 14:55:37 -05001094int drm_connector_attach_content_protection_property(
1095 struct drm_connector *connector);
Daniel Vetter52217192016-08-12 22:48:50 +02001096int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
1097int drm_mode_create_suggested_offset_properties(struct drm_device *dev);
1098
1099int drm_mode_connector_set_path_property(struct drm_connector *connector,
1100 const char *path);
1101int drm_mode_connector_set_tile_property(struct drm_connector *connector);
1102int drm_mode_connector_update_edid_property(struct drm_connector *connector,
1103 const struct edid *edid);
Manasi Navare40ee6fb2016-12-16 12:29:06 +02001104void drm_mode_connector_set_link_status_property(struct drm_connector *connector,
1105 uint64_t link_status);
Hans de Goede8d70f3952017-11-25 20:35:49 +01001106int drm_connector_init_panel_orientation_property(
1107 struct drm_connector *connector, int width, int height);
Daniel Vetterafb21ea62016-08-31 18:09:04 +02001108
1109/**
Daniel Vetter9498c192016-11-14 12:58:24 +01001110 * struct drm_tile_group - Tile group metadata
1111 * @refcount: reference count
1112 * @dev: DRM device
1113 * @id: tile group id exposed to userspace
1114 * @group_data: Sink-private data identifying this group
1115 *
1116 * @group_data corresponds to displayid vend/prod/serial for external screens
1117 * with an EDID.
1118 */
1119struct drm_tile_group {
1120 struct kref refcount;
1121 struct drm_device *dev;
1122 int id;
1123 u8 group_data[8];
1124};
1125
1126struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
1127 char topology[8]);
1128struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
1129 char topology[8]);
1130void drm_mode_put_tile_group(struct drm_device *dev,
1131 struct drm_tile_group *tg);
1132
1133/**
Daniel Vetter613051d2016-12-14 00:08:06 +01001134 * struct drm_connector_list_iter - connector_list iterator
1135 *
1136 * This iterator tracks state needed to be able to walk the connector_list
1137 * within struct drm_mode_config. Only use together with
Thierry Redingb982dab2017-02-28 15:46:43 +01001138 * drm_connector_list_iter_begin(), drm_connector_list_iter_end() and
Daniel Vetter613051d2016-12-14 00:08:06 +01001139 * drm_connector_list_iter_next() respectively the convenience macro
1140 * drm_for_each_connector_iter().
1141 */
1142struct drm_connector_list_iter {
1143/* private: */
1144 struct drm_device *dev;
1145 struct drm_connector *conn;
1146};
1147
Thierry Redingb982dab2017-02-28 15:46:43 +01001148void drm_connector_list_iter_begin(struct drm_device *dev,
1149 struct drm_connector_list_iter *iter);
Daniel Vetter613051d2016-12-14 00:08:06 +01001150struct drm_connector *
1151drm_connector_list_iter_next(struct drm_connector_list_iter *iter);
Thierry Redingb982dab2017-02-28 15:46:43 +01001152void drm_connector_list_iter_end(struct drm_connector_list_iter *iter);
Daniel Vetter613051d2016-12-14 00:08:06 +01001153
1154/**
1155 * drm_for_each_connector_iter - connector_list iterator macro
Daniel Vetterea0dd852016-12-29 21:48:26 +01001156 * @connector: &struct drm_connector pointer used as cursor
1157 * @iter: &struct drm_connector_list_iter
Daniel Vetter613051d2016-12-14 00:08:06 +01001158 *
1159 * Note that @connector is only valid within the list body, if you want to use
Thierry Redingb982dab2017-02-28 15:46:43 +01001160 * @connector after calling drm_connector_list_iter_end() then you need to grab
Gabriel Krisman Bertazi5e851c92017-04-20 21:38:19 -03001161 * your own reference first using drm_connector_get().
Daniel Vetter613051d2016-12-14 00:08:06 +01001162 */
1163#define drm_for_each_connector_iter(connector, iter) \
1164 while ((connector = drm_connector_list_iter_next(iter)))
1165
Daniel Vetter52217192016-08-12 22:48:50 +02001166#endif