xref: /linux/include/drm/drm_connector.h (revision f27fb7e315216b8bddf29297542c471368a672b4)
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/llist.h>
28 #include <linux/ctype.h>
29 #include <linux/hdmi.h>
30 #include <linux/notifier.h>
31 #include <linux/workqueue.h>
32 #include <drm/drm_mode_object.h>
33 #include <drm/drm_util.h>
34 #include <drm/drm_property.h>
35 
36 #include <uapi/drm/drm_mode.h>
37 
38 struct drm_connector_helper_funcs;
39 struct drm_modeset_acquire_ctx;
40 struct drm_device;
41 struct drm_crtc;
42 struct drm_display_mode;
43 struct drm_encoder;
44 struct drm_panel;
45 struct drm_property;
46 struct drm_property_blob;
47 struct drm_printer;
48 struct drm_privacy_screen;
49 struct drm_edid;
50 struct edid;
51 struct hdmi_codec_daifmt;
52 struct hdmi_codec_params;
53 struct i2c_adapter;
54 
55 enum drm_connector_force {
56 	DRM_FORCE_UNSPECIFIED,
57 	DRM_FORCE_OFF,
58 	DRM_FORCE_ON,         /* force on analog part normally */
59 	DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */
60 };
61 
62 /**
63  * enum drm_connector_status - status for a &drm_connector
64  *
65  * This enum is used to track the connector status. There are no separate
66  * #defines for the uapi!
67  */
68 enum drm_connector_status {
69 	/**
70 	 * @connector_status_connected: The connector is definitely connected to
71 	 * a sink device, and can be enabled.
72 	 */
73 	connector_status_connected = 1,
74 	/**
75 	 * @connector_status_disconnected: The connector isn't connected to a
76 	 * sink device which can be autodetect. For digital outputs like DP or
77 	 * HDMI (which can be realiable probed) this means there's really
78 	 * nothing there. It is driver-dependent whether a connector with this
79 	 * status can be lit up or not.
80 	 */
81 	connector_status_disconnected = 2,
82 	/**
83 	 * @connector_status_unknown: The connector's status could not be
84 	 * reliably detected. This happens when probing would either cause
85 	 * flicker (like load-detection when the connector is in use), or when a
86 	 * hardware resource isn't available (like when load-detection needs a
87 	 * free CRTC). It should be possible to light up the connector with one
88 	 * of the listed fallback modes. For default configuration userspace
89 	 * should only try to light up connectors with unknown status when
90 	 * there's not connector with @connector_status_connected.
91 	 */
92 	connector_status_unknown = 3,
93 };
94 
95 /**
96  * enum drm_connector_registration_state - userspace registration status for
97  * a &drm_connector
98  *
99  * This enum is used to track the status of initializing a connector and
100  * registering it with userspace, so that DRM can prevent bogus modesets on
101  * connectors that no longer exist.
102  */
103 enum drm_connector_registration_state {
104 	/**
105 	 * @DRM_CONNECTOR_INITIALIZING: The connector has just been created,
106 	 * but has yet to be exposed to userspace. There should be no
107 	 * additional restrictions to how the state of this connector may be
108 	 * modified.
109 	 */
110 	DRM_CONNECTOR_INITIALIZING = 0,
111 
112 	/**
113 	 * @DRM_CONNECTOR_REGISTERED: The connector has been fully initialized
114 	 * and registered with sysfs, as such it has been exposed to
115 	 * userspace. There should be no additional restrictions to how the
116 	 * state of this connector may be modified.
117 	 */
118 	DRM_CONNECTOR_REGISTERED = 1,
119 
120 	/**
121 	 * @DRM_CONNECTOR_UNREGISTERED: The connector has either been exposed
122 	 * to userspace and has since been unregistered and removed from
123 	 * userspace, or the connector was unregistered before it had a chance
124 	 * to be exposed to userspace (e.g. still in the
125 	 * @DRM_CONNECTOR_INITIALIZING state). When a connector is
126 	 * unregistered, there are additional restrictions to how its state
127 	 * may be modified:
128 	 *
129 	 * - An unregistered connector may only have its DPMS changed from
130 	 *   On->Off. Once DPMS is changed to Off, it may not be switched back
131 	 *   to On.
132 	 * - Modesets are not allowed on unregistered connectors, unless they
133 	 *   would result in disabling its assigned CRTCs. This means
134 	 *   disabling a CRTC on an unregistered connector is OK, but enabling
135 	 *   one is not.
136 	 * - Removing a CRTC from an unregistered connector is OK, but new
137 	 *   CRTCs may never be assigned to an unregistered connector.
138 	 */
139 	DRM_CONNECTOR_UNREGISTERED = 2,
140 };
141 
142 enum subpixel_order {
143 	SubPixelUnknown = 0,
144 	SubPixelHorizontalRGB,
145 	SubPixelHorizontalBGR,
146 	SubPixelVerticalRGB,
147 	SubPixelVerticalBGR,
148 	SubPixelNone,
149 
150 };
151 
152 /**
153  * enum drm_connector_tv_mode - Analog TV output mode
154  *
155  * This enum is used to indicate the TV output mode used on an analog TV
156  * connector.
157  *
158  * WARNING: The values of this enum is uABI since they're exposed in the
159  * "TV mode" connector property.
160  */
161 enum drm_connector_tv_mode {
162 	/**
163 	 * @DRM_MODE_TV_MODE_NTSC: CCIR System M (aka 525-lines)
164 	 * together with the NTSC Color Encoding.
165 	 */
166 	DRM_MODE_TV_MODE_NTSC,
167 
168 	/**
169 	 * @DRM_MODE_TV_MODE_NTSC_443: Variant of
170 	 * @DRM_MODE_TV_MODE_NTSC. Uses a color subcarrier frequency
171 	 * of 4.43 MHz.
172 	 */
173 	DRM_MODE_TV_MODE_NTSC_443,
174 
175 	/**
176 	 * @DRM_MODE_TV_MODE_NTSC_J: Variant of @DRM_MODE_TV_MODE_NTSC
177 	 * used in Japan. Uses a black level equals to the blanking
178 	 * level.
179 	 */
180 	DRM_MODE_TV_MODE_NTSC_J,
181 
182 	/**
183 	 * @DRM_MODE_TV_MODE_PAL: CCIR System B together with the PAL
184 	 * color system.
185 	 */
186 	DRM_MODE_TV_MODE_PAL,
187 
188 	/**
189 	 * @DRM_MODE_TV_MODE_PAL_M: CCIR System M (aka 525-lines)
190 	 * together with the PAL color encoding
191 	 */
192 	DRM_MODE_TV_MODE_PAL_M,
193 
194 	/**
195 	 * @DRM_MODE_TV_MODE_PAL_N: CCIR System N together with the PAL
196 	 * color encoding. It uses 625 lines, but has a color subcarrier
197 	 * frequency of 3.58MHz, the SECAM color space, and narrower
198 	 * channels compared to most of the other PAL variants.
199 	 */
200 	DRM_MODE_TV_MODE_PAL_N,
201 
202 	/**
203 	 * @DRM_MODE_TV_MODE_SECAM: CCIR System B together with the
204 	 * SECAM color system.
205 	 */
206 	DRM_MODE_TV_MODE_SECAM,
207 
208 	/**
209 	 * @DRM_MODE_TV_MODE_MONOCHROME: Use timings appropriate to
210 	 * the DRM mode, including equalizing pulses for a 525-line
211 	 * or 625-line mode, with no pedestal or color encoding.
212 	 */
213 	DRM_MODE_TV_MODE_MONOCHROME,
214 
215 	/**
216 	 * @DRM_MODE_TV_MODE_MAX: Number of analog TV output modes.
217 	 *
218 	 * Internal implementation detail; this is not uABI.
219 	 */
220 	DRM_MODE_TV_MODE_MAX,
221 };
222 
223 /**
224  * struct drm_scrambling: sink's scrambling support.
225  */
226 struct drm_scrambling {
227 	/**
228 	 * @supported: scrambling supported for rates > 340 Mhz.
229 	 */
230 	bool supported;
231 	/**
232 	 * @low_rates: scrambling supported for rates <= 340 Mhz.
233 	 */
234 	bool low_rates;
235 };
236 
237 /*
238  * struct drm_scdc - Information about scdc capabilities of a HDMI 2.0 sink
239  *
240  * Provides SCDC register support and capabilities related information on a
241  * HDMI 2.0 sink. In case of a HDMI 1.4 sink, all parameter must be 0.
242  */
243 struct drm_scdc {
244 	/**
245 	 * @supported: status control & data channel present.
246 	 */
247 	bool supported;
248 	/**
249 	 * @read_request: sink is capable of generating scdc read request.
250 	 */
251 	bool read_request;
252 	/**
253 	 * @scrambling: sink's scrambling capabilities
254 	 */
255 	struct drm_scrambling scrambling;
256 };
257 
258 /**
259  * struct drm_hdmi_vrr_cap - Information about VRR capabilities of a HDMI sink
260  *
261  * Describes the VRR support provided by HDMI 2.1 sink. The information is
262  * fetched fom additional HFVSDB blocks defined for HDMI 2.1.
263  */
264 struct drm_hdmi_vrr_cap {
265 	/** @fva: flag for Fast VActive (Quick Frame Transport) support */
266 	bool fva;
267 
268 	/** @mcnmvrr: flag for Negative M VRR support */
269 	bool cnmvrr;
270 
271 	/** @mcinema_vrr: flag for Cinema VRR support */
272 	bool cinema_vrr;
273 
274 	/** @mdelta: flag for limited frame-to-frame compensation support */
275 	bool mdelta;
276 
277 	/**
278 	 * @vrr_min : minimum supported variable refresh rate in Hz.
279 	 * Valid values only inide 1 - 48 range
280 	 */
281 	u16 vrr_min;
282 
283 	/**
284 	 * @vrr_max : maximum supported variable refresh rate in Hz (optional).
285 	 * Valid values are either 0 (max based on video mode) or >= 100
286 	 */
287 	u16 vrr_max;
288 
289 	/**
290 	 * @supported: flag for vrr support based on checking for VRRmin and
291 	 * VRRmax values having correct values.
292 	 */
293 	bool supported;
294 };
295 
296 /**
297  * struct drm_hdmi_dsc_cap - DSC capabilities of HDMI sink
298  *
299  * Describes the DSC support provided by HDMI 2.1 sink.
300  * The information is fetched fom additional HFVSDB blocks defined
301  * for HDMI 2.1.
302  */
303 struct drm_hdmi_dsc_cap {
304 	/** @v_1p2: flag for dsc1.2 version support by sink */
305 	bool v_1p2;
306 
307 	/** @native_420: Does sink support DSC with 4:2:0 compression */
308 	bool native_420;
309 
310 	/**
311 	 * @all_bpp: Does sink support all bpp with 4:4:4: or 4:2:2
312 	 * compressed formats
313 	 */
314 	bool all_bpp;
315 
316 	/**
317 	 * @bpc_supported: compressed bpc supported by sink : 10, 12 or 16 bpc
318 	 */
319 	u8 bpc_supported;
320 
321 	/** @max_slices: maximum number of Horizontal slices supported by */
322 	u8 max_slices;
323 
324 	/** @clk_per_slice : max pixel clock in MHz supported per slice */
325 	int clk_per_slice;
326 
327 	/** @max_lanes : dsc max lanes supported for Fixed rate Link training */
328 	u8 max_lanes;
329 
330 	/** @max_frl_rate_per_lane : maximum frl rate with DSC per lane */
331 	u8 max_frl_rate_per_lane;
332 
333 	/** @total_chunk_kbytes: max size of chunks in KBs supported per line*/
334 	u8 total_chunk_kbytes;
335 };
336 
337 /**
338  * struct drm_hdmi_info - runtime information about the connected HDMI sink
339  *
340  * Describes if a given display supports advanced HDMI 2.0 features.
341  * This information is available in CEA-861-F extension blocks (like HF-VSDB).
342  */
343 struct drm_hdmi_info {
344 	/** @scdc: sink's scdc support and capabilities */
345 	struct drm_scdc scdc;
346 
347 	/**
348 	 * @y420_vdb_modes: bitmap of modes which can support ycbcr420
349 	 * output only (not normal RGB/YCBCR444/422 outputs). The max VIC
350 	 * defined by the CEA-861-G spec is 219, so the size is 256 bits to map
351 	 * up to 256 VICs.
352 	 */
353 	unsigned long y420_vdb_modes[BITS_TO_LONGS(256)];
354 
355 	/**
356 	 * @y420_cmdb_modes: bitmap of modes which can support ycbcr420
357 	 * output also, along with normal HDMI outputs. The max VIC defined by
358 	 * the CEA-861-G spec is 219, so the size is 256 bits to map up to 256
359 	 * VICs.
360 	 */
361 	unsigned long y420_cmdb_modes[BITS_TO_LONGS(256)];
362 
363 	/** @y420_dc_modes: bitmap of deep color support index */
364 	u8 y420_dc_modes;
365 
366 	/** @max_frl_rate_per_lane: support fixed rate link */
367 	u8 max_frl_rate_per_lane;
368 
369 	/** @max_lanes: supported by sink */
370 	u8 max_lanes;
371 
372 	/** @fapa_start_location: flag for the FAPA in blanking support */
373 	bool fapa_start_location;
374 
375 	/** @allm: flag for Auto Low Latency Mode support by sink */
376 	bool allm;
377 
378 	/** @vrr_cap: VRR capabilities of the sink */
379 	struct drm_hdmi_vrr_cap vrr_cap;
380 
381 	/** @dsc_cap: DSC capabilities of the sink */
382 	struct drm_hdmi_dsc_cap dsc_cap;
383 };
384 
385 /**
386  * enum drm_link_status - connector's link_status property value
387  *
388  * This enum is used as the connector's link status property value.
389  * It is set to the values defined in uapi.
390  *
391  * @DRM_LINK_STATUS_GOOD: DP Link is Good as a result of successful
392  *                        link training
393  * @DRM_LINK_STATUS_BAD: DP Link is BAD as a result of link training
394  *                       failure
395  */
396 enum drm_link_status {
397 	DRM_LINK_STATUS_GOOD = DRM_MODE_LINK_STATUS_GOOD,
398 	DRM_LINK_STATUS_BAD = DRM_MODE_LINK_STATUS_BAD,
399 };
400 
401 /**
402  * enum drm_panel_orientation - panel_orientation info for &drm_display_info
403  *
404  * This enum is used to track the (LCD) panel orientation. There are no
405  * separate #defines for the uapi!
406  *
407  * @DRM_MODE_PANEL_ORIENTATION_UNKNOWN: The drm driver has not provided any
408  *					panel orientation information (normal
409  *					for non panels) in this case the "panel
410  *					orientation" connector prop will not be
411  *					attached.
412  * @DRM_MODE_PANEL_ORIENTATION_NORMAL:	The top side of the panel matches the
413  *					top side of the device's casing.
414  * @DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP: The top side of the panel matches the
415  *					bottom side of the device's casing, iow
416  *					the panel is mounted upside-down.
417  * @DRM_MODE_PANEL_ORIENTATION_LEFT_UP:	The left side of the panel matches the
418  *					top side of the device's casing.
419  * @DRM_MODE_PANEL_ORIENTATION_RIGHT_UP: The right side of the panel matches the
420  *					top side of the device's casing.
421  */
422 enum drm_panel_orientation {
423 	DRM_MODE_PANEL_ORIENTATION_UNKNOWN = -1,
424 	DRM_MODE_PANEL_ORIENTATION_NORMAL = 0,
425 	DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP,
426 	DRM_MODE_PANEL_ORIENTATION_LEFT_UP,
427 	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
428 };
429 
430 /**
431  * enum drm_hdmi_broadcast_rgb - Broadcast RGB Selection for an HDMI @drm_connector
432  */
433 enum drm_hdmi_broadcast_rgb {
434 	/**
435 	 * @DRM_HDMI_BROADCAST_RGB_AUTO: The RGB range is selected
436 	 * automatically based on the mode.
437 	 */
438 	DRM_HDMI_BROADCAST_RGB_AUTO,
439 
440 	/**
441 	 * @DRM_HDMI_BROADCAST_RGB_FULL: Full range RGB is forced.
442 	 */
443 	DRM_HDMI_BROADCAST_RGB_FULL,
444 
445 	/**
446 	 * @DRM_HDMI_BROADCAST_RGB_LIMITED: Limited range RGB is forced.
447 	 */
448 	DRM_HDMI_BROADCAST_RGB_LIMITED,
449 };
450 
451 const char *
452 drm_hdmi_connector_get_broadcast_rgb_name(enum drm_hdmi_broadcast_rgb broadcast_rgb);
453 
454 /**
455  * struct drm_monitor_range_info - Panel's Monitor range in EDID for
456  * &drm_display_info
457  *
458  * This struct is used to store a frequency range supported by panel
459  * as parsed from EDID's detailed monitor range descriptor block.
460  *
461  * @min_vfreq: This is the min supported refresh rate in Hz from
462  *             EDID's detailed monitor range.
463  * @max_vfreq: This is the max supported refresh rate in Hz from
464  *             EDID's detailed monitor range
465  */
466 struct drm_monitor_range_info {
467 	u16 min_vfreq;
468 	u16 max_vfreq;
469 };
470 
471 /**
472  * struct drm_luminance_range_info - Panel's luminance range for
473  * &drm_display_info. Calculated using data in EDID
474  *
475  * This struct is used to store a luminance range supported by panel
476  * as calculated using data from EDID's static hdr metadata.
477  *
478  * @min_luminance: This is the min supported luminance value
479  *
480  * @max_luminance: This is the max supported luminance value
481  */
482 struct drm_luminance_range_info {
483 	u32 min_luminance;
484 	u32 max_luminance;
485 };
486 
487 /**
488  * enum drm_privacy_screen_status - privacy screen status
489  *
490  * This enum is used to track and control the state of the integrated privacy
491  * screen present on some display panels, via the "privacy-screen sw-state"
492  * and "privacy-screen hw-state" properties. Note the _LOCKED enum values
493  * are only valid for the "privacy-screen hw-state" property.
494  *
495  * @PRIVACY_SCREEN_DISABLED:
496  *  The privacy-screen on the panel is disabled
497  * @PRIVACY_SCREEN_ENABLED:
498  *  The privacy-screen on the panel is enabled
499  * @PRIVACY_SCREEN_DISABLED_LOCKED:
500  *  The privacy-screen on the panel is disabled and locked (cannot be changed)
501  * @PRIVACY_SCREEN_ENABLED_LOCKED:
502  *  The privacy-screen on the panel is enabled and locked (cannot be changed)
503  */
504 enum drm_privacy_screen_status {
505 	PRIVACY_SCREEN_DISABLED = 0,
506 	PRIVACY_SCREEN_ENABLED,
507 	PRIVACY_SCREEN_DISABLED_LOCKED,
508 	PRIVACY_SCREEN_ENABLED_LOCKED,
509 };
510 
511 /**
512  * enum drm_colorspace - color space
513  *
514  * This enum is a consolidated colorimetry list supported by HDMI and
515  * DP protocol standard. The respective connectors will register
516  * a property with the subset of this list (supported by that
517  * respective protocol). Userspace will set the colorspace through
518  * a colorspace property which will be created and exposed to
519  * userspace.
520  *
521  * DP definitions come from the DP v2.0 spec
522  * HDMI definitions come from the CTA-861-H spec
523   *
524  * @DRM_MODE_COLORIMETRY_DEFAULT:
525  *   Driver specific behavior.
526  * @DRM_MODE_COLORIMETRY_NO_DATA:
527  *   Driver specific behavior.
528  * @DRM_MODE_COLORIMETRY_SMPTE_170M_YCC:
529  *   (HDMI)
530  *   SMPTE ST 170M colorimetry format
531  * @DRM_MODE_COLORIMETRY_BT709_YCC:
532  *   (HDMI, DP)
533  *   ITU-R BT.709 colorimetry format
534  * @DRM_MODE_COLORIMETRY_XVYCC_601:
535  *   (HDMI, DP)
536  *   xvYCC601 colorimetry format
537  * @DRM_MODE_COLORIMETRY_XVYCC_709:
538  *   (HDMI, DP)
539  *   xvYCC709 colorimetry format
540  * @DRM_MODE_COLORIMETRY_SYCC_601:
541  *   (HDMI, DP)
542  *   sYCC601 colorimetry format
543  * @DRM_MODE_COLORIMETRY_OPYCC_601:
544  *   (HDMI, DP)
545  *   opYCC601 colorimetry format
546  * @DRM_MODE_COLORIMETRY_OPRGB:
547  *   (HDMI, DP)
548  *   opRGB colorimetry format
549  * @DRM_MODE_COLORIMETRY_BT2020_CYCC:
550  *   (HDMI, DP)
551  *   ITU-R BT.2020 Y'c C'bc C'rc (constant luminance) colorimetry format
552  * @DRM_MODE_COLORIMETRY_BT2020_RGB:
553  *   (HDMI, DP)
554  *   ITU-R BT.2020 R' G' B' colorimetry format
555  * @DRM_MODE_COLORIMETRY_BT2020_YCC:
556  *   (HDMI, DP)
557  *   ITU-R BT.2020 Y' C'b C'r colorimetry format
558  * @DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65:
559  *   (HDMI)
560  *   SMPTE ST 2113 P3D65 colorimetry format
561  * @DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER:
562  *   (HDMI)
563  *   SMPTE ST 2113 P3DCI colorimetry format
564  * @DRM_MODE_COLORIMETRY_RGB_WIDE_FIXED:
565  *   (DP)
566  *   RGB wide gamut fixed point colorimetry format
567  * @DRM_MODE_COLORIMETRY_RGB_WIDE_FLOAT:
568  *   (DP)
569  *   RGB wide gamut floating point
570  *   (scRGB (IEC 61966-2-2)) colorimetry format
571  * @DRM_MODE_COLORIMETRY_BT601_YCC:
572  *   (DP)
573  *   ITU-R BT.601 colorimetry format
574  *   The DP spec does not say whether this is the 525 or the 625
575  *   line version.
576  * @DRM_MODE_COLORIMETRY_COUNT:
577  *   Not a valid value; merely used four counting
578  */
579 enum drm_colorspace {
580 	/* For Default case, driver will set the colorspace */
581 	DRM_MODE_COLORIMETRY_DEFAULT 		= 0,
582 	/* CEA 861 Normal Colorimetry options */
583 	DRM_MODE_COLORIMETRY_NO_DATA		= 0,
584 	DRM_MODE_COLORIMETRY_SMPTE_170M_YCC	= 1,
585 	DRM_MODE_COLORIMETRY_BT709_YCC		= 2,
586 	/* CEA 861 Extended Colorimetry Options */
587 	DRM_MODE_COLORIMETRY_XVYCC_601		= 3,
588 	DRM_MODE_COLORIMETRY_XVYCC_709		= 4,
589 	DRM_MODE_COLORIMETRY_SYCC_601		= 5,
590 	DRM_MODE_COLORIMETRY_OPYCC_601		= 6,
591 	DRM_MODE_COLORIMETRY_OPRGB		= 7,
592 	DRM_MODE_COLORIMETRY_BT2020_CYCC	= 8,
593 	DRM_MODE_COLORIMETRY_BT2020_RGB		= 9,
594 	DRM_MODE_COLORIMETRY_BT2020_YCC		= 10,
595 	/* Additional Colorimetry extension added as part of CTA 861.G */
596 	DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65	= 11,
597 	DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER	= 12,
598 	/* Additional Colorimetry Options added for DP 1.4a VSC Colorimetry Format */
599 	DRM_MODE_COLORIMETRY_RGB_WIDE_FIXED	= 13,
600 	DRM_MODE_COLORIMETRY_RGB_WIDE_FLOAT	= 14,
601 	DRM_MODE_COLORIMETRY_BT601_YCC		= 15,
602 	DRM_MODE_COLORIMETRY_COUNT
603 };
604 
605 /**
606  * enum drm_output_color_format - Output Color Format
607  *
608  * This enum is a consolidated color format list supported by
609  * connectors. It's only ever really been used for HDMI and DP so far,
610  * so it's not exhaustive and can be extended to represent other formats
611  * in the future.
612  *
613  *
614  * @DRM_OUTPUT_COLOR_FORMAT_RGB444:
615  *   RGB output format
616  * @DRM_OUTPUT_COLOR_FORMAT_YCBCR444:
617  *   YCbCr 4:4:4 output format (ie. not subsampled)
618  * @DRM_OUTPUT_COLOR_FORMAT_YCBCR422:
619  *   YCbCr 4:2:2 output format (ie. with horizontal subsampling)
620  * @DRM_OUTPUT_COLOR_FORMAT_YCBCR420:
621  *   YCbCr 4:2:0 output format (ie. with horizontal and vertical subsampling)
622  * @DRM_OUTPUT_COLOR_FORMAT_COUNT:
623  *   Number of valid output color format values in this enum
624  */
625 enum drm_output_color_format {
626 	DRM_OUTPUT_COLOR_FORMAT_RGB444 = 0,
627 	DRM_OUTPUT_COLOR_FORMAT_YCBCR444,
628 	DRM_OUTPUT_COLOR_FORMAT_YCBCR422,
629 	DRM_OUTPUT_COLOR_FORMAT_YCBCR420,
630 	DRM_OUTPUT_COLOR_FORMAT_COUNT,
631 };
632 
633 /**
634  * enum drm_connector_color_format - Connector Color Format Request
635  *
636  * This enum, unlike &enum drm_output_color_format, is used to specify requests
637  * for a specific color format on a connector through the DRM "color format"
638  * property. The difference is that it has an "AUTO" value to specify that
639  * no specific choice has been made.
640  */
641 enum drm_connector_color_format {
642 	/**
643 	 * @DRM_CONNECTOR_COLOR_FORMAT_AUTO: The driver or display protocol
644 	 * helpers should pick a suitable color format. All implementations of a
645 	 * specific display protocol must behave the same way with "AUTO", but
646 	 * different display protocols do not necessarily have the same "AUTO"
647 	 * semantics.
648 	 *
649 	 * For HDMI, "AUTO" picks RGB, but falls back to YCbCr 4:2:0 if the
650 	 * bandwidth required for full-scale RGB is not available, or the mode
651 	 * is YCbCr 4:2:0-only, as long as the mode and output both support
652 	 * YCbCr 4:2:0.
653 	 *
654 	 * For display protocols other than HDMI, the recursive bridge chain
655 	 * format selection picks the first chain of bridge formats that works,
656 	 * as has already been the case before the introduction of the "color
657 	 * format" property. Non-HDMI bridges should therefore either sort their
658 	 * bus output formats by preference, or agree on a unified auto format
659 	 * selection logic that's implemented in a common state helper (like
660 	 * how HDMI does it).
661 	 */
662 	DRM_CONNECTOR_COLOR_FORMAT_AUTO = 0,
663 
664 	/**
665 	 * @DRM_CONNECTOR_COLOR_FORMAT_RGB444: RGB output format. The
666 	 * quantization range depends on the value of the "Broadcast RGB"
667 	 * property if it is present on the connector.
668 	 */
669 	DRM_CONNECTOR_COLOR_FORMAT_RGB444,
670 
671 	/**
672 	 * @DRM_CONNECTOR_COLOR_FORMAT_YCBCR444: YCbCr 4:4:4 output format (ie.
673 	 * not subsampled). Quantization range is "Limited" by default.
674 	 */
675 	DRM_CONNECTOR_COLOR_FORMAT_YCBCR444,
676 
677 	/**
678 	 * @DRM_CONNECTOR_COLOR_FORMAT_YCBCR422: YCbCr 4:2:2 output format (ie.
679 	 * with horizontal subsampling). Quantization range is "Limited" by
680 	 * default.
681 	 */
682 	DRM_CONNECTOR_COLOR_FORMAT_YCBCR422,
683 
684 	/**
685 	 * @DRM_CONNECTOR_COLOR_FORMAT_YCBCR420: YCbCr 4:2:0 output format (ie.
686 	 * with horizontal and vertical subsampling). Quantization range is
687 	 * "Limited" by default.
688 	 */
689 	DRM_CONNECTOR_COLOR_FORMAT_YCBCR420,
690 
691 	/**
692 	 * @DRM_CONNECTOR_COLOR_FORMAT_COUNT: Number of valid connector color
693 	 * format values in this enum
694 	 */
695 	DRM_CONNECTOR_COLOR_FORMAT_COUNT,
696 };
697 
698 const char *
699 drm_hdmi_connector_get_output_format_name(enum drm_output_color_format fmt);
700 
701 /**
702  * enum drm_bus_flags - bus_flags info for &drm_display_info
703  *
704  * This enum defines signal polarities and clock edge information for signals on
705  * a bus as bitmask flags.
706  *
707  * The clock edge information is conveyed by two sets of symbols,
708  * DRM_BUS_FLAGS_*_DRIVE_\* and DRM_BUS_FLAGS_*_SAMPLE_\*. When this enum is
709  * used to describe a bus from the point of view of the transmitter, the
710  * \*_DRIVE_\* flags should be used. When used from the point of view of the
711  * receiver, the \*_SAMPLE_\* flags should be used. The \*_DRIVE_\* and
712  * \*_SAMPLE_\* flags alias each other, with the \*_SAMPLE_POSEDGE and
713  * \*_SAMPLE_NEGEDGE flags being equal to \*_DRIVE_NEGEDGE and \*_DRIVE_POSEDGE
714  * respectively. This simplifies code as signals are usually sampled on the
715  * opposite edge of the driving edge. Transmitters and receivers may however
716  * need to take other signal timings into account to convert between driving
717  * and sample edges.
718  */
719 enum drm_bus_flags {
720 	/**
721 	 * @DRM_BUS_FLAG_DE_LOW:
722 	 *
723 	 * The Data Enable signal is active low
724 	 */
725 	DRM_BUS_FLAG_DE_LOW = BIT(0),
726 
727 	/**
728 	 * @DRM_BUS_FLAG_DE_HIGH:
729 	 *
730 	 * The Data Enable signal is active high
731 	 */
732 	DRM_BUS_FLAG_DE_HIGH = BIT(1),
733 
734 	/**
735 	 * @DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE:
736 	 *
737 	 * Data is driven on the rising edge of the pixel clock
738 	 */
739 	DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE = BIT(2),
740 
741 	/**
742 	 * @DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE:
743 	 *
744 	 * Data is driven on the falling edge of the pixel clock
745 	 */
746 	DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE = BIT(3),
747 
748 	/**
749 	 * @DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE:
750 	 *
751 	 * Data is sampled on the rising edge of the pixel clock
752 	 */
753 	DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE = DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE,
754 
755 	/**
756 	 * @DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE:
757 	 *
758 	 * Data is sampled on the falling edge of the pixel clock
759 	 */
760 	DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE = DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE,
761 
762 	/**
763 	 * @DRM_BUS_FLAG_DATA_MSB_TO_LSB:
764 	 *
765 	 * Data is transmitted MSB to LSB on the bus
766 	 */
767 	DRM_BUS_FLAG_DATA_MSB_TO_LSB = BIT(4),
768 
769 	/**
770 	 * @DRM_BUS_FLAG_DATA_LSB_TO_MSB:
771 	 *
772 	 * Data is transmitted LSB to MSB on the bus
773 	 */
774 	DRM_BUS_FLAG_DATA_LSB_TO_MSB = BIT(5),
775 
776 	/**
777 	 * @DRM_BUS_FLAG_SYNC_DRIVE_POSEDGE:
778 	 *
779 	 * Sync signals are driven on the rising edge of the pixel clock
780 	 */
781 	DRM_BUS_FLAG_SYNC_DRIVE_POSEDGE = BIT(6),
782 
783 	/**
784 	 * @DRM_BUS_FLAG_SYNC_DRIVE_NEGEDGE:
785 	 *
786 	 * Sync signals are driven on the falling edge of the pixel clock
787 	 */
788 	DRM_BUS_FLAG_SYNC_DRIVE_NEGEDGE = BIT(7),
789 
790 	/**
791 	 * @DRM_BUS_FLAG_SYNC_SAMPLE_POSEDGE:
792 	 *
793 	 * Sync signals are sampled on the rising edge of the pixel clock
794 	 */
795 	DRM_BUS_FLAG_SYNC_SAMPLE_POSEDGE = DRM_BUS_FLAG_SYNC_DRIVE_NEGEDGE,
796 
797 	/**
798 	 * @DRM_BUS_FLAG_SYNC_SAMPLE_NEGEDGE:
799 	 *
800 	 * Sync signals are sampled on the falling edge of the pixel clock
801 	 */
802 	DRM_BUS_FLAG_SYNC_SAMPLE_NEGEDGE = DRM_BUS_FLAG_SYNC_DRIVE_POSEDGE,
803 
804 	/**
805 	 * @DRM_BUS_FLAG_SHARP_SIGNALS:
806 	 *
807 	 *  Set if the Sharp-specific signals (SPL, CLS, PS, REV) must be used
808 	 */
809 	DRM_BUS_FLAG_SHARP_SIGNALS = BIT(8),
810 };
811 
812 /**
813  * struct drm_amd_vsdb_info - AMD-specific VSDB information
814  *
815  * This structure holds information parsed from the AMD Vendor-Specific Data
816  * Block (VSDB) versions 1 to 3.
817  */
818 struct drm_amd_vsdb_info {
819 	/**
820 	 * @version: Version of the Vendor-Specific Data Block (VSDB)
821 	 */
822 	u8 version;
823 
824 	/**
825 	 * @freesync_supported: FreeSync (variable refresh rate) supported by panel
826 	 */
827 	bool freesync_supported;
828 
829 	/**
830 	 * @min_frame_rate: FreeSync minimum refresh rate in Hz
831 	 */
832 	u16 min_frame_rate;
833 
834 	/**
835 	 * @max_frame_rate: FreeSync maximum refresh rate in Hz
836 	 */
837 	u16 max_frame_rate;
838 
839 	/**
840 	 * @freesync_vcp_code: MCCS VCP code for FreeSync
841 	 */
842 	u8 freesync_vcp_code;
843 
844 	/**
845 	 * @replay_mode: Panel Replay supported
846 	 */
847 	bool replay_mode;
848 
849 	/**
850 	 * @panel_type: Panel technology type
851 	 */
852 	u8 panel_type;
853 
854 	/**
855 	 * @luminance_range1: Luminance for max back light
856 	 */
857 	struct drm_luminance_range_info luminance_range1;
858 
859 	/**
860 	 * @luminance_range2: Luminance for min back light
861 	 */
862 	struct drm_luminance_range_info luminance_range2;
863 };
864 
865 /**
866  * struct drm_display_info - runtime data about the connected sink
867  *
868  * Describes a given display (e.g. CRT or flat panel) and its limitations. For
869  * fixed display sinks like built-in panels there's not much difference between
870  * this and &struct drm_connector. But for sinks with a real cable this
871  * structure is meant to describe all the things at the other end of the cable.
872  *
873  * For sinks which provide an EDID this can be filled out by calling
874  * drm_add_edid_modes().
875  */
876 struct drm_display_info {
877 	/**
878 	 * @width_mm: Physical width in mm.
879 	 */
880 	unsigned int width_mm;
881 
882 	/**
883 	 * @height_mm: Physical height in mm.
884 	 */
885 	unsigned int height_mm;
886 
887 	/**
888 	 * @bpc: Maximum bits per color channel. Used by HDMI and DP outputs.
889 	 */
890 	unsigned int bpc;
891 
892 	/**
893 	 * @subpixel_order: Subpixel order of LCD panels.
894 	 */
895 	enum subpixel_order subpixel_order;
896 
897 	/**
898 	 * @panel_orientation: Read only connector property for built-in panels,
899 	 * indicating the orientation of the panel vs the device's casing.
900 	 * drm_connector_init() sets this to DRM_MODE_PANEL_ORIENTATION_UNKNOWN.
901 	 * When not UNKNOWN this gets used by the drm_fb_helpers to rotate the
902 	 * fb to compensate and gets exported as prop to userspace.
903 	 */
904 	int panel_orientation;
905 
906 	/**
907 	 * @color_formats: HDMI Color formats, selects between RGB and
908 	 * YCbCr modes. Uses a bitmask of DRM_OUTPUT_COLOR_FORMAT\_
909 	 * defines, which are _not_ the same ones as used to describe
910 	 * the pixel format in framebuffers, and also don't match the
911 	 * formats in @bus_formats which are shared with v4l.
912 	 */
913 	u32 color_formats;
914 
915 	/**
916 	 * @bus_formats: Pixel data format on the wire, somewhat redundant with
917 	 * @color_formats. Array of size @num_bus_formats encoded using
918 	 * MEDIA_BUS_FMT\_ defines shared with v4l and media drivers.
919 	 */
920 	const u32 *bus_formats;
921 	/**
922 	 * @num_bus_formats: Size of @bus_formats array.
923 	 */
924 	unsigned int num_bus_formats;
925 
926 	/**
927 	 * @bus_flags: Additional information (like pixel signal polarity) for
928 	 * the pixel data on the bus, using &enum drm_bus_flags values
929 	 * DRM_BUS_FLAGS\_.
930 	 */
931 	u32 bus_flags;
932 
933 	/**
934 	 * @max_tmds_clock: Maximum TMDS clock rate supported by the
935 	 * sink in kHz. 0 means undefined.
936 	 */
937 	int max_tmds_clock;
938 
939 	/**
940 	 * @dvi_dual: Dual-link DVI sink?
941 	 */
942 	bool dvi_dual;
943 
944 	/**
945 	 * @is_hdmi: True if the sink is an HDMI device.
946 	 *
947 	 * This field shall be used instead of calling
948 	 * drm_detect_hdmi_monitor() when possible.
949 	 */
950 	bool is_hdmi;
951 
952 	/**
953 	 * @has_audio: True if the sink supports audio.
954 	 *
955 	 * This field shall be used instead of calling
956 	 * drm_detect_monitor_audio() when possible.
957 	 */
958 	bool has_audio;
959 
960 	/**
961 	 * @has_hdmi_infoframe: Does the sink support the HDMI infoframe?
962 	 */
963 	bool has_hdmi_infoframe;
964 
965 	/**
966 	 * @rgb_quant_range_selectable: Does the sink support selecting
967 	 * the RGB quantization range?
968 	 */
969 	bool rgb_quant_range_selectable;
970 
971 	/**
972 	 * @edid_hdmi_rgb444_dc_modes: Mask of supported hdmi deep color modes
973 	 * in RGB 4:4:4. Even more stuff redundant with @bus_formats.
974 	 */
975 	u8 edid_hdmi_rgb444_dc_modes;
976 
977 	/**
978 	 * @edid_hdmi_ycbcr444_dc_modes: Mask of supported hdmi deep color
979 	 * modes in YCbCr 4:4:4. Even more stuff redundant with @bus_formats.
980 	 */
981 	u8 edid_hdmi_ycbcr444_dc_modes;
982 
983 	/**
984 	 * @cea_rev: CEA revision of the HDMI sink.
985 	 */
986 	u8 cea_rev;
987 
988 	/**
989 	 * @hdmi: advance features of a HDMI sink.
990 	 */
991 	struct drm_hdmi_info hdmi;
992 
993 	/**
994 	 * @hdr_sink_metadata: HDR Metadata Information read from sink
995 	 */
996 	struct hdr_sink_metadata hdr_sink_metadata;
997 
998 	/**
999 	 * @non_desktop: Non desktop display (HMD).
1000 	 */
1001 	bool non_desktop;
1002 
1003 	/**
1004 	 * @monitor_range: Frequency range supported by monitor range descriptor
1005 	 */
1006 	struct drm_monitor_range_info monitor_range;
1007 
1008 	/**
1009 	 * @luminance_range: Luminance range supported by panel
1010 	 */
1011 	struct drm_luminance_range_info luminance_range;
1012 
1013 	/**
1014 	 * @mso_stream_count: eDP Multi-SST Operation (MSO) stream count from
1015 	 * the DisplayID VESA vendor block. 0 for conventional Single-Stream
1016 	 * Transport (SST), or 2 or 4 MSO streams.
1017 	 */
1018 	u8 mso_stream_count;
1019 
1020 	/**
1021 	 * @mso_pixel_overlap: eDP MSO segment pixel overlap, 0-8 pixels.
1022 	 */
1023 	u8 mso_pixel_overlap;
1024 
1025 	/**
1026 	 * @max_dsc_bpp: Maximum DSC target bitrate, if it is set to 0 the
1027 	 * monitor's default value is used instead.
1028 	 */
1029 	u32 max_dsc_bpp;
1030 
1031 	/**
1032 	 * @vics: Array of vics_len VICs. Internal to EDID parsing.
1033 	 */
1034 	u8 *vics;
1035 
1036 	/**
1037 	 * @vics_len: Number of elements in vics. Internal to EDID parsing.
1038 	 */
1039 	int vics_len;
1040 
1041 	/**
1042 	 * @quirks: EDID based quirks. DRM core and drivers can query the
1043 	 * @drm_edid_quirk quirks using drm_edid_has_quirk(), the rest of
1044 	 * the quirks also tracked here are internal to EDID parsing.
1045 	 */
1046 	u32 quirks;
1047 
1048 	/**
1049 	 * @source_physical_address: Source Physical Address from HDMI
1050 	 * Vendor-Specific Data Block, for CEC usage.
1051 	 *
1052 	 * Defaults to CEC_PHYS_ADDR_INVALID (0xffff).
1053 	 */
1054 	u16 source_physical_address;
1055 
1056 	/**
1057 	 * @amd_vsdb: AMD-specific VSDB information.
1058 	 */
1059 	struct drm_amd_vsdb_info amd_vsdb;
1060 
1061 	/**
1062 	 * @panel_type: Panel type from DisplayID Display Parameters
1063 	 * Data Block (tag 0x21). Uses DRM_MODE_PANEL_TYPE_* constants.
1064 	 */
1065 	u8 panel_type;
1066 };
1067 
1068 int drm_display_info_set_bus_formats(struct drm_display_info *info,
1069 				     const u32 *formats,
1070 				     unsigned int num_formats);
1071 
1072 /**
1073  * struct drm_connector_tv_margins - TV connector related margins
1074  *
1075  * Describes the margins in pixels to put around the image on TV
1076  * connectors to deal with overscan.
1077  */
1078 struct drm_connector_tv_margins {
1079 	/**
1080 	 * @bottom: Bottom margin in pixels.
1081 	 */
1082 	unsigned int bottom;
1083 
1084 	/**
1085 	 * @left: Left margin in pixels.
1086 	 */
1087 	unsigned int left;
1088 
1089 	/**
1090 	 * @right: Right margin in pixels.
1091 	 */
1092 	unsigned int right;
1093 
1094 	/**
1095 	 * @top: Top margin in pixels.
1096 	 */
1097 	unsigned int top;
1098 };
1099 
1100 /**
1101  * struct drm_tv_connector_state - TV connector related states
1102  * @select_subconnector: selected subconnector
1103  * @subconnector: detected subconnector
1104  * @margins: TV margins
1105  * @legacy_mode: Legacy TV mode, driver specific value
1106  * @mode: TV mode
1107  * @brightness: brightness in percent
1108  * @contrast: contrast in percent
1109  * @flicker_reduction: flicker reduction in percent
1110  * @overscan: overscan in percent
1111  * @saturation: saturation in percent
1112  * @hue: hue in percent
1113  */
1114 struct drm_tv_connector_state {
1115 	enum drm_mode_subconnector select_subconnector;
1116 	enum drm_mode_subconnector subconnector;
1117 	struct drm_connector_tv_margins margins;
1118 	unsigned int legacy_mode;
1119 	unsigned int mode;
1120 	unsigned int brightness;
1121 	unsigned int contrast;
1122 	unsigned int flicker_reduction;
1123 	unsigned int overscan;
1124 	unsigned int saturation;
1125 	unsigned int hue;
1126 };
1127 
1128 /**
1129  * struct drm_connector_hdmi_infoframe - HDMI Infoframe container
1130  */
1131 struct drm_connector_hdmi_infoframe {
1132 	/**
1133 	 * @data: HDMI Infoframe structure
1134 	 */
1135 	union hdmi_infoframe data;
1136 
1137 	/**
1138 	 * @set: Is the content of @data valid?
1139 	 */
1140 	bool set;
1141 };
1142 
1143 /*
1144  * struct drm_connector_hdmi_state - HDMI state container
1145  */
1146 struct drm_connector_hdmi_state {
1147 	/**
1148 	 * @broadcast_rgb: Connector property to pass the
1149 	 * Broadcast RGB selection value.
1150 	 */
1151 	enum drm_hdmi_broadcast_rgb broadcast_rgb;
1152 
1153 	/**
1154 	 * @infoframes: HDMI Infoframes matching that state
1155 	 */
1156 	struct {
1157 		/**
1158 		 * @avi: AVI Infoframes structure matching our
1159 		 * state.
1160 		 */
1161 		struct drm_connector_hdmi_infoframe avi;
1162 
1163 		/**
1164 		 * @hdr_drm: DRM (Dynamic Range and Mastering)
1165 		 * Infoframes structure matching our state.
1166 		 */
1167 		struct drm_connector_hdmi_infoframe hdr_drm;
1168 
1169 		/**
1170 		 * @spd: SPD Infoframes structure matching our
1171 		 * state.
1172 		 */
1173 		struct drm_connector_hdmi_infoframe spd;
1174 
1175 		/**
1176 		 * @vendor: HDMI Vendor Infoframes structure
1177 		 * matching our state.
1178 		 */
1179 		struct drm_connector_hdmi_infoframe hdmi;
1180 	} infoframes;
1181 
1182 	/**
1183 	 * @is_limited_range: Is the output supposed to use a limited
1184 	 * RGB Quantization Range or not?
1185 	 */
1186 	bool is_limited_range;
1187 
1188 	/**
1189 	 * @output_bpc: Bits per color channel to output.
1190 	 */
1191 	unsigned int output_bpc;
1192 
1193 	/**
1194 	 * @output_format: Pixel format to output in.
1195 	 */
1196 	enum drm_output_color_format output_format;
1197 
1198 	/**
1199 	 * @tmds_char_rate: TMDS Character Rate, in Hz.
1200 	 */
1201 	unsigned long long tmds_char_rate;
1202 
1203 	/**
1204 	 * @scrambler_needed: Whether HDMI 2.0 SCDC scrambling is required
1205 	 * for the negotiated mode/bpc/format.
1206 	 *
1207 	 * Computed by drm_atomic_helper_connector_hdmi_check() according to
1208 	 * the HDMI 2.0 specification: scrambling is mandatory above a 340 MHz
1209 	 * TMDS character rate. Optional scrambling at lower rates is
1210 	 * deliberately not requested by the helper.
1211 	 */
1212 	bool scrambler_needed;
1213 };
1214 
1215 /**
1216  * struct drm_connector_state - mutable connector state
1217  */
1218 struct drm_connector_state {
1219 	/** @connector: backpointer to the connector */
1220 	struct drm_connector *connector;
1221 
1222 	/**
1223 	 * @crtc: CRTC to connect connector to, NULL if disabled.
1224 	 *
1225 	 * Do not change this directly, use drm_atomic_set_crtc_for_connector()
1226 	 * instead.
1227 	 */
1228 	struct drm_crtc *crtc;
1229 
1230 	/**
1231 	 * @best_encoder:
1232 	 *
1233 	 * Used by the atomic helpers to select the encoder, through the
1234 	 * &drm_connector_helper_funcs.atomic_best_encoder or
1235 	 * &drm_connector_helper_funcs.best_encoder callbacks.
1236 	 *
1237 	 * This is also used in the atomic helpers to map encoders to their
1238 	 * current and previous connectors, see
1239 	 * drm_atomic_get_old_connector_for_encoder() and
1240 	 * drm_atomic_get_new_connector_for_encoder().
1241 	 *
1242 	 * NOTE: Atomic drivers must fill this out (either themselves or through
1243 	 * helpers), for otherwise the GETCONNECTOR and GETENCODER IOCTLs will
1244 	 * not return correct data to userspace.
1245 	 */
1246 	struct drm_encoder *best_encoder;
1247 
1248 	/**
1249 	 * @link_status: Connector link_status to keep track of whether link is
1250 	 * GOOD or BAD to notify userspace if retraining is necessary.
1251 	 */
1252 	enum drm_link_status link_status;
1253 
1254 	/** @state: backpointer to global drm_atomic_commit */
1255 	struct drm_atomic_commit *state;
1256 
1257 	/**
1258 	 * @commit: Tracks the pending commit to prevent use-after-free conditions.
1259 	 *
1260 	 * Is only set when @crtc is NULL.
1261 	 */
1262 	struct drm_crtc_commit *commit;
1263 
1264 	/** @tv: TV connector state */
1265 	struct drm_tv_connector_state tv;
1266 
1267 	/**
1268 	 * @self_refresh_aware:
1269 	 *
1270 	 * This tracks whether a connector is aware of the self refresh state.
1271 	 * It should be set to true for those connector implementations which
1272 	 * understand the self refresh state. This is needed since the crtc
1273 	 * registers the self refresh helpers and it doesn't know if the
1274 	 * connectors downstream have implemented self refresh entry/exit.
1275 	 *
1276 	 * Drivers should set this to true in atomic_check if they know how to
1277 	 * handle self_refresh requests.
1278 	 */
1279 	bool self_refresh_aware;
1280 
1281 	/**
1282 	 * @picture_aspect_ratio: Connector property to control the
1283 	 * HDMI infoframe aspect ratio setting.
1284 	 *
1285 	 * The %DRM_MODE_PICTURE_ASPECT_\* values much match the
1286 	 * values for &enum hdmi_picture_aspect
1287 	 */
1288 	enum hdmi_picture_aspect picture_aspect_ratio;
1289 
1290 	/**
1291 	 * @content_type: Connector property to control the
1292 	 * HDMI infoframe content type setting.
1293 	 * The %DRM_MODE_CONTENT_TYPE_\* values much
1294 	 * match the values.
1295 	 */
1296 	unsigned int content_type;
1297 
1298 	/**
1299 	 * @hdcp_content_type: Connector property to pass the type of
1300 	 * protected content. This is most commonly used for HDCP.
1301 	 */
1302 	unsigned int hdcp_content_type;
1303 
1304 	/**
1305 	 * @scaling_mode: Connector property to control the
1306 	 * upscaling, mostly used for built-in panels.
1307 	 */
1308 	unsigned int scaling_mode;
1309 
1310 	/**
1311 	 * @content_protection: Connector property to request content
1312 	 * protection. This is most commonly used for HDCP.
1313 	 */
1314 	unsigned int content_protection;
1315 
1316 	/**
1317 	 * @colorspace: State variable for Connector property to request
1318 	 * colorspace change on Sink. This is most commonly used to switch
1319 	 * to wider color gamuts like BT2020.
1320 	 */
1321 	enum drm_colorspace colorspace;
1322 
1323 	/**
1324 	 * @color_format: State variable for Connector property to request
1325 	 * color format change on Sink. This is most commonly used to switch
1326 	 * between RGB to YUV and vice-versa.
1327 	 */
1328 	enum drm_connector_color_format color_format;
1329 
1330 	/**
1331 	 * @writeback_job: Writeback job for writeback connectors
1332 	 *
1333 	 * Holds the framebuffer and out-fence for a writeback connector. As
1334 	 * the writeback completion may be asynchronous to the normal commit
1335 	 * cycle, the writeback job lifetime is managed separately from the
1336 	 * normal atomic state by this object.
1337 	 *
1338 	 * See also: drm_writeback_queue_job() and
1339 	 * drm_writeback_signal_completion()
1340 	 */
1341 	struct drm_writeback_job *writeback_job;
1342 
1343 	/**
1344 	 * @max_requested_bpc: Connector property to limit the maximum bit
1345 	 * depth of the pixels.
1346 	 */
1347 	u8 max_requested_bpc;
1348 
1349 	/**
1350 	 * @max_bpc: Connector max_bpc based on the requested max_bpc property
1351 	 * and the connector bpc limitations obtained from edid.
1352 	 */
1353 	u8 max_bpc;
1354 
1355 	/**
1356 	 * @privacy_screen_sw_state: See :ref:`Standard Connector
1357 	 * Properties<standard_connector_properties>`
1358 	 */
1359 	enum drm_privacy_screen_status privacy_screen_sw_state;
1360 
1361 	/**
1362 	 * @hdr_output_metadata:
1363 	 * DRM blob property for HDR output metadata
1364 	 */
1365 	struct drm_property_blob *hdr_output_metadata;
1366 
1367 	/**
1368 	 * @hdmi: HDMI-related variable and properties. Filled by
1369 	 * @drm_atomic_helper_connector_hdmi_check().
1370 	 */
1371 	struct drm_connector_hdmi_state hdmi;
1372 };
1373 
1374 struct drm_connector_hdmi_audio_funcs {
1375 	/**
1376 	 * @startup:
1377 	 *
1378 	 * Called when ASoC starts an audio stream setup. The
1379 	 * @startup() is optional.
1380 	 *
1381 	 * Returns:
1382 	 * 0 on success, a negative error code otherwise
1383 	 */
1384 	int (*startup)(struct drm_connector *connector);
1385 
1386 	/**
1387 	 * @prepare:
1388 	 * Configures HDMI-encoder for audio stream. Can be called
1389 	 * multiple times for each setup. Mandatory.
1390 	 *
1391 	 * Returns:
1392 	 * 0 on success, a negative error code otherwise
1393 	 */
1394 	int (*prepare)(struct drm_connector *connector,
1395 		       struct hdmi_codec_daifmt *fmt,
1396 		       struct hdmi_codec_params *hparms);
1397 
1398 	/**
1399 	 * @shutdown:
1400 	 *
1401 	 * Shut down the audio stream. Mandatory.
1402 	 *
1403 	 * Returns:
1404 	 * 0 on success, a negative error code otherwise
1405 	 */
1406 	void (*shutdown)(struct drm_connector *connector);
1407 
1408 	/**
1409 	 * @mute_stream:
1410 	 *
1411 	 * Mute/unmute HDMI audio stream. The @mute_stream callback is
1412 	 * optional.
1413 	 *
1414 	 * Returns:
1415 	 * 0 on success, a negative error code otherwise
1416 	 */
1417 	int (*mute_stream)(struct drm_connector *connector,
1418 			   bool enable, int direction);
1419 };
1420 
1421 void drm_connector_cec_phys_addr_invalidate(struct drm_connector *connector);
1422 void drm_connector_cec_phys_addr_set(struct drm_connector *connector);
1423 
1424 /**
1425  * struct drm_connector_cec_funcs - drm_hdmi_connector control functions
1426  */
1427 struct drm_connector_cec_funcs {
1428 	/**
1429 	 * @phys_addr_invalidate: mark CEC physical address as invalid
1430 	 *
1431 	 * The callback to mark CEC physical address as invalid, abstracting
1432 	 * the operation.
1433 	 */
1434 	void (*phys_addr_invalidate)(struct drm_connector *connector);
1435 
1436 	/**
1437 	 * @phys_addr_set: set CEC physical address
1438 	 *
1439 	 * The callback to set CEC physical address, abstracting the operation.
1440 	 */
1441 	void (*phys_addr_set)(struct drm_connector *connector, u16 addr);
1442 };
1443 
1444 /**
1445  * struct drm_connector_infoframe_funcs - InfoFrame-related functions
1446  */
1447 struct drm_connector_infoframe_funcs {
1448 	/**
1449 	 * @clear_infoframe:
1450 	 *
1451 	 * This callback is invoked through
1452 	 * @drm_atomic_helper_connector_hdmi_update_infoframes during a
1453 	 * commit to clear the infoframes into the hardware. It will be
1454 	 * called once for each frame type to be disabled.
1455 	 *
1456 	 * The @clear_infoframe callback is mandatory for AVI and HDMI-VS
1457 	 * InfoFrame types.
1458 	 *
1459 	 * Returns:
1460 	 * 0 on success, a negative error code otherwise
1461 	 */
1462 	int (*clear_infoframe)(struct drm_connector *connector);
1463 
1464 	/**
1465 	 * @write_infoframe:
1466 	 *
1467 	 * This callback is invoked through
1468 	 * @drm_atomic_helper_connector_hdmi_update_infoframes during a
1469 	 * commit to program the infoframes into the hardware. It will
1470 	 * be called for every updated infoframe type.
1471 	 *
1472 	 * The @write_infoframe callback is mandatory for AVI and HDMI-VS
1473 	 * InfoFrame types.
1474 	 *
1475 	 * Returns:
1476 	 * 0 on success, a negative error code otherwise
1477 	 */
1478 	int (*write_infoframe)(struct drm_connector *connector,
1479 			       const u8 *buffer, size_t len);
1480 
1481 };
1482 
1483 /**
1484  * struct drm_connector_hdmi_funcs - drm_hdmi_connector control functions
1485  * and controller capabilities
1486  */
1487 struct drm_connector_hdmi_funcs {
1488 	/**
1489 	 * @vendor: HDMI Controller Vendor name.
1490 	 */
1491 	const char *vendor;
1492 
1493 	/**
1494 	 * @product: HDMI Controller Product name
1495 	 */
1496 	const char *product;
1497 
1498 	/**
1499 	 * @supported_hdmi_ver:
1500 	 *
1501 	 * Maximum HDMI specification version supported by the controller side
1502 	 * of this connector. This describes the controller capability only;
1503 	 * the effective link capabilities may be further restricted by the
1504 	 * sink, bridge, or mode validation.
1505 	 */
1506 	enum hdmi_version supported_hdmi_ver;
1507 
1508 	/**
1509 	 * @supported_tmds_char_rate:
1510 	 *
1511 	 * Maximum TMDS character rate supported by the controller, in Hz.
1512 	 * A value of 0 means the core should use the default limit implied by
1513 	 * @supported_hdmi_ver.
1514 	 */
1515 	unsigned long long supported_tmds_char_rate;
1516 
1517 	/**
1518 	 * @supported_formats:
1519 	 *
1520 	 * Bitmask of @drm_output_color_format listing supported output formats.
1521 	 */
1522 	unsigned long supported_formats;
1523 
1524 	/**
1525 	 * @max_bpc: Maximum bits per char the HDMI connector supports.
1526 	 */
1527 	unsigned int max_bpc;
1528 
1529 	/**
1530 	 * @tmds_char_rate_valid:
1531 	 *
1532 	 * This callback is invoked at atomic_check time to figure out
1533 	 * whether a particular TMDS character rate is supported by the
1534 	 * driver.
1535 	 *
1536 	 * The @tmds_char_rate_valid callback is optional.
1537 	 *
1538 	 * Returns:
1539 	 *
1540 	 * Either &drm_mode_status.MODE_OK or one of the failure reasons
1541 	 * in &enum drm_mode_status.
1542 	 */
1543 	enum drm_mode_status
1544 	(*tmds_char_rate_valid)(const struct drm_connector *connector,
1545 				const struct drm_display_mode *mode,
1546 				unsigned long long tmds_rate);
1547 
1548 	/**
1549 	 * @read_edid:
1550 	 *
1551 	 * This callback is used by the framework as a replacement for reading
1552 	 * the EDID from connector->ddc. It is still recommended to provide
1553 	 * connector->ddc instead of implementing this callback. Returned EDID
1554 	 * should be freed via the drm_edid_free().
1555 	 *
1556 	 * The @read_edid callback is optional.
1557 	 *
1558 	 * Returns:
1559 	 * Valid EDID on success, NULL in case of failure.
1560 	 */
1561 	const struct drm_edid *(*read_edid)(struct drm_connector *connector);
1562 
1563 	/**
1564 	 * @scrambler_enable:
1565 	 *
1566 	 * The callback is invoked via @drm_connector_hdmi_enable_scrambling
1567 	 * during commit to setup SCDC scrambling and high TMDS clock ratio on
1568 	 * the source side.
1569 	 *
1570 	 * The @scrambler_enable callback is mandatory if HDMI 2.0 is to be
1571 	 * supported.
1572 	 *
1573 	 * Returns:
1574 	 * 0 on success, a negative error code otherwise
1575 	 */
1576 	int (*scrambler_enable)(struct drm_connector *connector);
1577 
1578 	/**
1579 	 * @scrambler_disable:
1580 	 *
1581 	 * The callback is invoked via @drm_connector_hdmi_disable_scrambling
1582 	 * during commit to tear down SCDC scrambling and high TMDS clock ratio
1583 	 * on the source side.
1584 	 *
1585 	 * The @scrambler_disable callback is mandatory if HDMI 2.0 is to be
1586 	 * supported.
1587 	 *
1588 	 * Returns:
1589 	 * 0 on success, a negative error code otherwise
1590 	 */
1591 	int (*scrambler_disable)(struct drm_connector *connector);
1592 
1593 	/**
1594 	 * @avi:
1595 	 *
1596 	 * Set of callbacks for handling the AVI InfoFrame. These callbacks are
1597 	 * mandatory.
1598 	 */
1599 	struct drm_connector_infoframe_funcs avi;
1600 
1601 	/**
1602 	 * @hdmi:
1603 	 *
1604 	 * Set of callbacks for handling the HDMI Vendor-Specific InfoFrame.
1605 	 * These callbacks are mandatory.
1606 	 */
1607 	struct drm_connector_infoframe_funcs hdmi;
1608 
1609 	/**
1610 	 * @audio:
1611 	 *
1612 	 * Set of callbacks for handling the Audio InfoFrame. These callbacks
1613 	 * are optional, but they are required for drivers which use
1614 	 * drm_atomic_helper_connector_hdmi_update_audio_infoframe().
1615 	 */
1616 	struct drm_connector_infoframe_funcs audio;
1617 
1618 	/**
1619 	 * @hdr_drm:
1620 	 *
1621 	 * Set of callbacks for handling the HDR DRM InfoFrame. These callbacks
1622 	 * are mandatory if HDR output is to be supported.
1623 	 */
1624 	struct drm_connector_infoframe_funcs hdr_drm;
1625 
1626 	/**
1627 	 * @spd:
1628 	 *
1629 	 * Set of callbacks for handling the SPD InfoFrame. These callbacks are
1630 	 * optional.
1631 	 */
1632 	struct drm_connector_infoframe_funcs spd;
1633 };
1634 
1635 /**
1636  * struct drm_connector_funcs - control connectors on a given device
1637  *
1638  * Each CRTC may have one or more connectors attached to it.  The functions
1639  * below allow the core DRM code to control connectors, enumerate available modes,
1640  * etc.
1641  */
1642 struct drm_connector_funcs {
1643 	/**
1644 	 * @dpms:
1645 	 *
1646 	 * Legacy entry point to set the per-connector DPMS state. Legacy DPMS
1647 	 * is exposed as a standard property on the connector, but diverted to
1648 	 * this callback in the drm core. Note that atomic drivers don't
1649 	 * implement the 4 level DPMS support on the connector any more, but
1650 	 * instead only have an on/off "ACTIVE" property on the CRTC object.
1651 	 *
1652 	 * This hook is not used by atomic drivers, remapping of the legacy DPMS
1653 	 * property is entirely handled in the DRM core.
1654 	 *
1655 	 * RETURNS:
1656 	 *
1657 	 * 0 on success or a negative error code on failure.
1658 	 */
1659 	int (*dpms)(struct drm_connector *connector, int mode);
1660 
1661 	/**
1662 	 * @reset:
1663 	 *
1664 	 * Reset connector hardware and software state to off. This function isn't
1665 	 * called by the core directly, only through drm_mode_config_reset().
1666 	 * It's not a helper hook only for historical reasons.
1667 	 *
1668 	 * Atomic drivers can use drm_atomic_helper_connector_reset() to reset
1669 	 * atomic state using this hook.
1670 	 */
1671 	void (*reset)(struct drm_connector *connector);
1672 
1673 	/**
1674 	 * @detect:
1675 	 *
1676 	 * Check to see if anything is attached to the connector. The parameter
1677 	 * force is set to false whilst polling, true when checking the
1678 	 * connector due to a user request. force can be used by the driver to
1679 	 * avoid expensive, destructive operations during automated probing.
1680 	 *
1681 	 * This callback is optional, if not implemented the connector will be
1682 	 * considered as always being attached.
1683 	 *
1684 	 * FIXME:
1685 	 *
1686 	 * Note that this hook is only called by the probe helper. It's not in
1687 	 * the helper library vtable purely for historical reasons. The only DRM
1688 	 * core	entry point to probe connector state is @fill_modes.
1689 	 *
1690 	 * Note that the helper library will already hold
1691 	 * &drm_mode_config.connection_mutex. Drivers which need to grab additional
1692 	 * locks to avoid races with concurrent modeset changes need to use
1693 	 * &drm_connector_helper_funcs.detect_ctx instead.
1694 	 *
1695 	 * Also note that this callback can be called no matter the
1696 	 * state the connector is in. Drivers that need the underlying
1697 	 * device to be powered to perform the detection will first need
1698 	 * to make sure it's been properly enabled.
1699 	 *
1700 	 * RETURNS:
1701 	 *
1702 	 * drm_connector_status indicating the connector's status.
1703 	 */
1704 	enum drm_connector_status (*detect)(struct drm_connector *connector,
1705 					    bool force);
1706 
1707 	/**
1708 	 * @force:
1709 	 *
1710 	 * This function is called to update internal encoder state when the
1711 	 * connector is forced to a certain state by userspace, either through
1712 	 * the sysfs interfaces or on the kernel cmdline. In that case the
1713 	 * @detect callback isn't called.
1714 	 *
1715 	 * New drivers should implement
1716 	 * &drm_connector_helper_funcs.force_ctx instead, which gets passed
1717 	 * the modeset acquire context and thus allows taking additional
1718 	 * locks.  It takes precedence over this callback when both are
1719 	 * implemented.
1720 	 *
1721 	 * FIXME:
1722 	 *
1723 	 * Note that this hook is only called by the probe helper. It's not in
1724 	 * the helper library vtable purely for historical reasons. The only DRM
1725 	 * core	entry point to probe connector state is @fill_modes.
1726 	 */
1727 	void (*force)(struct drm_connector *connector);
1728 
1729 	/**
1730 	 * @fill_modes:
1731 	 *
1732 	 * Entry point for output detection and basic mode validation. The
1733 	 * driver should reprobe the output if needed (e.g. when hotplug
1734 	 * handling is unreliable), add all detected modes to &drm_connector.modes
1735 	 * and filter out any the device can't support in any configuration. It
1736 	 * also needs to filter out any modes wider or higher than the
1737 	 * parameters max_width and max_height indicate.
1738 	 *
1739 	 * The drivers must also prune any modes no longer valid from
1740 	 * &drm_connector.modes. Furthermore it must update
1741 	 * &drm_connector.status and &drm_connector.edid.  If no EDID has been
1742 	 * received for this output connector->edid must be NULL.
1743 	 *
1744 	 * Drivers using the probe helpers should use
1745 	 * drm_helper_probe_single_connector_modes() to implement this
1746 	 * function.
1747 	 *
1748 	 * RETURNS:
1749 	 *
1750 	 * The number of modes detected and filled into &drm_connector.modes.
1751 	 */
1752 	int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height);
1753 
1754 	/**
1755 	 * @set_property:
1756 	 *
1757 	 * This is the legacy entry point to update a property attached to the
1758 	 * connector.
1759 	 *
1760 	 * This callback is optional if the driver does not support any legacy
1761 	 * driver-private properties. For atomic drivers it is not used because
1762 	 * property handling is done entirely in the DRM core.
1763 	 *
1764 	 * RETURNS:
1765 	 *
1766 	 * 0 on success or a negative error code on failure.
1767 	 */
1768 	int (*set_property)(struct drm_connector *connector, struct drm_property *property,
1769 			     uint64_t val);
1770 
1771 	/**
1772 	 * @late_register:
1773 	 *
1774 	 * This optional hook can be used to register additional userspace
1775 	 * interfaces attached to the connector, light backlight control, i2c,
1776 	 * DP aux or similar interfaces. It is called late in the driver load
1777 	 * sequence from drm_connector_register() when registering all the
1778 	 * core drm connector interfaces. Everything added from this callback
1779 	 * should be unregistered in the early_unregister callback.
1780 	 *
1781 	 * This is called while holding &drm_connector.mutex.
1782 	 *
1783 	 * Returns:
1784 	 *
1785 	 * 0 on success, or a negative error code on failure.
1786 	 */
1787 	int (*late_register)(struct drm_connector *connector);
1788 
1789 	/**
1790 	 * @early_unregister:
1791 	 *
1792 	 * This optional hook should be used to unregister the additional
1793 	 * userspace interfaces attached to the connector from
1794 	 * late_register(). It is called from drm_connector_unregister(),
1795 	 * early in the driver unload sequence to disable userspace access
1796 	 * before data structures are torndown.
1797 	 *
1798 	 * This is called while holding &drm_connector.mutex.
1799 	 */
1800 	void (*early_unregister)(struct drm_connector *connector);
1801 
1802 	/**
1803 	 * @destroy:
1804 	 *
1805 	 * Clean up connector resources. This is called at driver unload time
1806 	 * through drm_mode_config_cleanup(). It can also be called at runtime
1807 	 * when a connector is being hot-unplugged for drivers that support
1808 	 * connector hotplugging (e.g. DisplayPort MST).
1809 	 */
1810 	void (*destroy)(struct drm_connector *connector);
1811 
1812 	/**
1813 	 * @atomic_create_state:
1814 	 *
1815 	 * Allocate a pristine, initialized, state for the connector
1816 	 * object and return it. This callback must have no side
1817 	 * effects: in particular, the returned state must not be
1818 	 * assigned to the object's state pointer and it must not affect
1819 	 * the hardware state.
1820 	 *
1821 	 * RETURNS:
1822 	 *
1823 	 * A new, pristine, connector state instance or an error pointer
1824 	 * on failure.
1825 	 */
1826 	struct drm_connector_state *(*atomic_create_state)(struct drm_connector *connector);
1827 
1828 	/**
1829 	 * @atomic_duplicate_state:
1830 	 *
1831 	 * Duplicate the current atomic state for this connector and return it.
1832 	 * The core and helpers guarantee that any atomic state duplicated with
1833 	 * this hook and still owned by the caller (i.e. not transferred to the
1834 	 * driver by calling &drm_mode_config_funcs.atomic_commit) will be
1835 	 * cleaned up by calling the @atomic_destroy_state hook in this
1836 	 * structure.
1837 	 *
1838 	 * This callback is mandatory for atomic drivers.
1839 	 *
1840 	 * Atomic drivers which don't subclass &struct drm_connector_state should use
1841 	 * drm_atomic_helper_connector_duplicate_state(). Drivers that subclass the
1842 	 * state structure to extend it with driver-private state should use
1843 	 * __drm_atomic_helper_connector_duplicate_state() to make sure shared state is
1844 	 * duplicated in a consistent fashion across drivers.
1845 	 *
1846 	 * It is an error to call this hook before &drm_connector.state has been
1847 	 * initialized correctly.
1848 	 *
1849 	 * NOTE:
1850 	 *
1851 	 * If the duplicate state references refcounted resources this hook must
1852 	 * acquire a reference for each of them. The driver must release these
1853 	 * references again in @atomic_destroy_state.
1854 	 *
1855 	 * RETURNS:
1856 	 *
1857 	 * Duplicated atomic state or NULL when the allocation failed.
1858 	 */
1859 	struct drm_connector_state *(*atomic_duplicate_state)(struct drm_connector *connector);
1860 
1861 	/**
1862 	 * @atomic_destroy_state:
1863 	 *
1864 	 * Destroy a state duplicated with @atomic_duplicate_state and release
1865 	 * or unreference all resources it references
1866 	 *
1867 	 * This callback is mandatory for atomic drivers.
1868 	 */
1869 	void (*atomic_destroy_state)(struct drm_connector *connector,
1870 				     struct drm_connector_state *state);
1871 
1872 	/**
1873 	 * @atomic_set_property:
1874 	 *
1875 	 * Decode a driver-private property value and store the decoded value
1876 	 * into the passed-in state structure. Since the atomic core decodes all
1877 	 * standardized properties (even for extensions beyond the core set of
1878 	 * properties which might not be implemented by all drivers) this
1879 	 * requires drivers to subclass the state structure.
1880 	 *
1881 	 * Such driver-private properties should really only be implemented for
1882 	 * truly hardware/vendor specific state. Instead it is preferred to
1883 	 * standardize atomic extension and decode the properties used to expose
1884 	 * such an extension in the core.
1885 	 *
1886 	 * Do not call this function directly, use
1887 	 * drm_atomic_connector_set_property() instead.
1888 	 *
1889 	 * This callback is optional if the driver does not support any
1890 	 * driver-private atomic properties.
1891 	 *
1892 	 * NOTE:
1893 	 *
1894 	 * This function is called in the state assembly phase of atomic
1895 	 * modesets, which can be aborted for any reason (including on
1896 	 * userspace's request to just check whether a configuration would be
1897 	 * possible). Drivers MUST NOT touch any persistent state (hardware or
1898 	 * software) or data structures except the passed in @state parameter.
1899 	 *
1900 	 * Also since userspace controls in which order properties are set this
1901 	 * function must not do any input validation (since the state update is
1902 	 * incomplete and hence likely inconsistent). Instead any such input
1903 	 * validation must be done in the various atomic_check callbacks.
1904 	 *
1905 	 * RETURNS:
1906 	 *
1907 	 * 0 if the property has been found, -EINVAL if the property isn't
1908 	 * implemented by the driver (which shouldn't ever happen, the core only
1909 	 * asks for properties attached to this connector). No other validation
1910 	 * is allowed by the driver. The core already checks that the property
1911 	 * value is within the range (integer, valid enum value, ...) the driver
1912 	 * set when registering the property.
1913 	 */
1914 	int (*atomic_set_property)(struct drm_connector *connector,
1915 				   struct drm_connector_state *state,
1916 				   struct drm_property *property,
1917 				   uint64_t val);
1918 
1919 	/**
1920 	 * @atomic_get_property:
1921 	 *
1922 	 * Reads out the decoded driver-private property. This is used to
1923 	 * implement the GETCONNECTOR IOCTL.
1924 	 *
1925 	 * Do not call this function directly, use
1926 	 * drm_atomic_connector_get_property() instead.
1927 	 *
1928 	 * This callback is optional if the driver does not support any
1929 	 * driver-private atomic properties.
1930 	 *
1931 	 * RETURNS:
1932 	 *
1933 	 * 0 on success, -EINVAL if the property isn't implemented by the
1934 	 * driver (which shouldn't ever happen, the core only asks for
1935 	 * properties attached to this connector).
1936 	 */
1937 	int (*atomic_get_property)(struct drm_connector *connector,
1938 				   const struct drm_connector_state *state,
1939 				   struct drm_property *property,
1940 				   uint64_t *val);
1941 
1942 	/**
1943 	 * @atomic_print_state:
1944 	 *
1945 	 * If driver subclasses &struct drm_connector_state, it should implement
1946 	 * this optional hook for printing additional driver specific state.
1947 	 *
1948 	 * Do not call this directly, use drm_atomic_connector_print_state()
1949 	 * instead.
1950 	 */
1951 	void (*atomic_print_state)(struct drm_printer *p,
1952 				   const struct drm_connector_state *state);
1953 
1954 	/**
1955 	 * @oob_hotplug_event:
1956 	 *
1957 	 * This will get called when a hotplug-event for a drm-connector
1958 	 * has been received from a source outside the display driver / device.
1959 	 */
1960 	void (*oob_hotplug_event)(struct drm_connector *connector,
1961 				  enum drm_connector_status status);
1962 
1963 	/**
1964 	 * @debugfs_init:
1965 	 *
1966 	 * Allows connectors to create connector-specific debugfs files.
1967 	 */
1968 	void (*debugfs_init)(struct drm_connector *connector, struct dentry *root);
1969 
1970 	/**
1971 	 * @color_format:
1972 	 *
1973 	 * Allows connectors to return a connector color format other than
1974 	 * @conn_state.color_format for purposes of e.g. display protocol
1975 	 * specific helper logic having already mapped it to an output format.
1976 	 */
1977 	enum drm_connector_color_format (*color_format)(
1978 		const struct drm_connector_state *conn_state);
1979 };
1980 
1981 /**
1982  * struct drm_cmdline_mode - DRM Mode passed through the kernel command-line
1983  *
1984  * Each connector can have an initial mode with additional options
1985  * passed through the kernel command line. This structure allows to
1986  * express those parameters and will be filled by the command-line
1987  * parser.
1988  */
1989 struct drm_cmdline_mode {
1990 	/**
1991 	 * @name:
1992 	 *
1993 	 * Name of the mode.
1994 	 */
1995 	char name[DRM_DISPLAY_MODE_LEN];
1996 
1997 	/**
1998 	 * @specified:
1999 	 *
2000 	 * Has a mode been read from the command-line?
2001 	 */
2002 	bool specified;
2003 
2004 	/**
2005 	 * @refresh_specified:
2006 	 *
2007 	 * Did the mode have a preferred refresh rate?
2008 	 */
2009 	bool refresh_specified;
2010 
2011 	/**
2012 	 * @bpp_specified:
2013 	 *
2014 	 * Did the mode have a preferred BPP?
2015 	 */
2016 	bool bpp_specified;
2017 
2018 	/**
2019 	 * @pixel_clock:
2020 	 *
2021 	 * Pixel Clock in kHz. Optional.
2022 	 */
2023 	unsigned int pixel_clock;
2024 
2025 	/**
2026 	 * @xres:
2027 	 *
2028 	 * Active resolution on the X axis, in pixels.
2029 	 */
2030 	int xres;
2031 
2032 	/**
2033 	 * @yres:
2034 	 *
2035 	 * Active resolution on the Y axis, in pixels.
2036 	 */
2037 	int yres;
2038 
2039 	/**
2040 	 * @bpp:
2041 	 *
2042 	 * Bits per pixels for the mode.
2043 	 */
2044 	int bpp;
2045 
2046 	/**
2047 	 * @refresh:
2048 	 *
2049 	 * Refresh rate, in Hertz.
2050 	 */
2051 	int refresh;
2052 
2053 	/**
2054 	 * @rb:
2055 	 *
2056 	 * Do we need to use reduced blanking?
2057 	 */
2058 	bool rb;
2059 
2060 	/**
2061 	 * @interlace:
2062 	 *
2063 	 * The mode is interlaced.
2064 	 */
2065 	bool interlace;
2066 
2067 	/**
2068 	 * @cvt:
2069 	 *
2070 	 * The timings will be calculated using the VESA Coordinated
2071 	 * Video Timings instead of looking up the mode from a table.
2072 	 */
2073 	bool cvt;
2074 
2075 	/**
2076 	 * @margins:
2077 	 *
2078 	 * Add margins to the mode calculation (1.8% of xres rounded
2079 	 * down to 8 pixels and 1.8% of yres).
2080 	 */
2081 	bool margins;
2082 
2083 	/**
2084 	 * @force:
2085 	 *
2086 	 * Ignore the hotplug state of the connector, and force its
2087 	 * state to one of the DRM_FORCE_* values.
2088 	 */
2089 	enum drm_connector_force force;
2090 
2091 	/**
2092 	 * @rotation_reflection:
2093 	 *
2094 	 * Initial rotation and reflection of the mode setup from the
2095 	 * command line. See DRM_MODE_ROTATE_* and
2096 	 * DRM_MODE_REFLECT_*. The only rotations supported are
2097 	 * DRM_MODE_ROTATE_0 and DRM_MODE_ROTATE_180.
2098 	 */
2099 	unsigned int rotation_reflection;
2100 
2101 	/**
2102 	 * @panel_orientation:
2103 	 *
2104 	 * drm-connector "panel orientation" property override value,
2105 	 * DRM_MODE_PANEL_ORIENTATION_UNKNOWN if not set.
2106 	 */
2107 	enum drm_panel_orientation panel_orientation;
2108 
2109 	/**
2110 	 * @tv_margins: TV margins to apply to the mode.
2111 	 */
2112 	struct drm_connector_tv_margins tv_margins;
2113 
2114 	/**
2115 	 * @tv_mode: TV mode standard. See DRM_MODE_TV_MODE_*.
2116 	 */
2117 	enum drm_connector_tv_mode tv_mode;
2118 
2119 	/**
2120 	 * @tv_mode_specified:
2121 	 *
2122 	 * Did the mode have a preferred TV mode?
2123 	 */
2124 	bool tv_mode_specified;
2125 };
2126 
2127 /**
2128  * struct drm_connector_hdmi_audio - DRM gemeric HDMI Codec-related structure
2129  *
2130  * HDMI drivers usually incorporate a HDMI Codec. This structure expresses the
2131  * generic HDMI Codec as used by the DRM HDMI Codec framework.
2132  */
2133 struct drm_connector_hdmi_audio {
2134 	/**
2135 	 * @funcs:
2136 	 *
2137 	 * Implementation of the HDMI codec functionality to be used by the DRM
2138 	 * HDMI Codec framework.
2139 	 */
2140 	const struct drm_connector_hdmi_audio_funcs *funcs;
2141 
2142 	/**
2143 	 * @codec_pdev:
2144 	 *
2145 	 * Platform device created to hold the HDMI Codec. It will be
2146 	 * automatically unregistered during drm_connector_cleanup().
2147 	 */
2148 	struct platform_device *codec_pdev;
2149 
2150 	/**
2151 	 * @lock:
2152 	 *
2153 	 * Mutex to protect @last_state, @plugged_cb and @plugged_cb_dev.
2154 	 */
2155 	struct mutex lock;
2156 
2157 	/**
2158 	 * @plugged_cb:
2159 	 *
2160 	 * Callback to be called when the HDMI sink get plugged to or unplugged
2161 	 * from this connector. This is assigned by the framework when
2162 	 * requested by the ASoC code.
2163 	 */
2164 	void (*plugged_cb)(struct device *dev, bool plugged);
2165 
2166 	/**
2167 	 * @plugged_cb_dev:
2168 	 *
2169 	 * The data for @plugged_cb(). It is being provided by the ASoC.
2170 	 */
2171 	struct device *plugged_cb_dev;
2172 
2173 	/**
2174 	 * @last_state:
2175 	 *
2176 	 * Last plugged state recored by the framework. It is used to correctly
2177 	 * report the state to @plugged_cb().
2178 	 */
2179 	bool last_state;
2180 
2181 	/**
2182 	 * @dai_port:
2183 	 *
2184 	 * The port in DT that is used for the Codec DAI.
2185 	 */
2186 	int dai_port;
2187 };
2188 
2189 /*
2190  * struct drm_connector_hdmi - DRM Connector HDMI-related structure
2191  */
2192 struct drm_connector_hdmi {
2193 #define DRM_CONNECTOR_HDMI_VENDOR_LEN	8
2194 	/**
2195 	 * @vendor: HDMI Controller Vendor Name
2196 	 */
2197 	unsigned char vendor[DRM_CONNECTOR_HDMI_VENDOR_LEN] __nonstring;
2198 
2199 #define DRM_CONNECTOR_HDMI_PRODUCT_LEN	16
2200 	/**
2201 	 * @product: HDMI Controller Product Name
2202 	 */
2203 	unsigned char product[DRM_CONNECTOR_HDMI_PRODUCT_LEN] __nonstring;
2204 
2205 	/**
2206 	 * @supported_formats: Bitmask of @drm_output_color_format
2207 	 * supported by the controller.
2208 	 */
2209 	unsigned long supported_formats;
2210 
2211 	/**
2212 	 * @max_tmds_char_rate: Maximum TMDS character rate, in Hz,
2213 	 * supported by the controller.
2214 	 *
2215 	 * This is inferred from &drm_connector_hdmi_funcs.supported_hdmi_ver,
2216 	 * by default. However, controllers may support a lower rate than that
2217 	 * specification version would imply. If that is the case, drivers are
2218 	 * expected to set &drm_connector_hdmi_funcs.supported_tmds_char_rate
2219 	 * to a non-zero value indicating the actual limit.
2220 	 */
2221 	unsigned long long max_tmds_char_rate;
2222 
2223 	/**
2224 	 * @scrambler_enabled: Tracks whether HDMI 2.0 scrambler is currently enabled.
2225 	 */
2226 	bool scrambler_enabled;
2227 
2228 	/**
2229 	 * @scdc_work: Work item currently used to monitor sink-side scrambling
2230 	 * status and retry setup if the sink resets it.
2231 	 */
2232 	struct delayed_work scdc_work;
2233 
2234 	/**
2235 	 * @scdc_work_initialized: Tracks whether @scdc_work has been set up via
2236 	 * INIT_DELAYED_WORK(). The work item is initialized lazily on the first
2237 	 * scrambling enable, so this guards the teardown paths against touching
2238 	 * an uninitialized work item.
2239 	 */
2240 	bool scdc_work_initialized;
2241 
2242 	/**
2243 	 * @funcs: HDMI connector Control Functions and controller capabilities
2244 	 */
2245 	const struct drm_connector_hdmi_funcs *funcs;
2246 
2247 	/**
2248 	 * @infoframes: Current Infoframes output by the connector
2249 	 */
2250 	struct {
2251 		/**
2252 		 * @lock: Mutex protecting against concurrent access to
2253 		 * the infoframes, most notably between KMS and ALSA.
2254 		 */
2255 		struct mutex lock;
2256 
2257 		/**
2258 		 * @audio: Current Audio Infoframes structure. Protected
2259 		 * by @lock.
2260 		 */
2261 		struct drm_connector_hdmi_infoframe audio;
2262 	} infoframes;
2263 };
2264 
2265 /**
2266  * struct drm_connector_cec - DRM Connector CEC-related structure
2267  */
2268 struct drm_connector_cec {
2269 	/**
2270 	 * @mutex: protects all fields in this structure.
2271 	 */
2272 	struct mutex mutex;
2273 
2274 	/**
2275 	 * @funcs: CEC Control Functions
2276 	 */
2277 	const struct drm_connector_cec_funcs *funcs;
2278 
2279 	/**
2280 	 * @data: CEC implementation-specific data
2281 	 */
2282 	void *data;
2283 };
2284 
2285 /**
2286  * struct drm_connector - central DRM connector control structure
2287  *
2288  * Each connector may be connected to one or more CRTCs, or may be clonable by
2289  * another connector if they can share a CRTC.  Each connector also has a specific
2290  * position in the broader display (referred to as a 'screen' though it could
2291  * span multiple monitors).
2292  */
2293 struct drm_connector {
2294 	/** @dev: parent DRM device */
2295 	struct drm_device *dev;
2296 	/** @kdev: kernel device for sysfs attributes */
2297 	struct device *kdev;
2298 	/** @attr: sysfs attributes */
2299 	struct device_attribute *attr;
2300 	/**
2301 	 * @fwnode: associated fwnode supplied by platform firmware
2302 	 *
2303 	 * Drivers can set this to associate a fwnode with a connector, drivers
2304 	 * are expected to get a reference on the fwnode when setting this.
2305 	 * drm_connector_cleanup() will call fwnode_handle_put() on this.
2306 	 */
2307 	struct fwnode_handle *fwnode;
2308 
2309 	/**
2310 	 * @head:
2311 	 *
2312 	 * List of all connectors on a @dev, linked from
2313 	 * &drm_mode_config.connector_list. Protected by
2314 	 * &drm_mode_config.connector_list_lock, but please only use
2315 	 * &drm_connector_list_iter to walk this list.
2316 	 */
2317 	struct list_head head;
2318 
2319 	/**
2320 	 * @global_connector_list_entry:
2321 	 *
2322 	 * Connector entry in the global connector-list, used by
2323 	 * drm_connector_find_by_fwnode().
2324 	 */
2325 	struct list_head global_connector_list_entry;
2326 
2327 	/** @base: base KMS object */
2328 	struct drm_mode_object base;
2329 
2330 	/** @name: human readable name, can be overwritten by the driver */
2331 	char *name;
2332 
2333 	/**
2334 	 * @mutex: Lock for general connector state, but currently only protects
2335 	 * @registered. Most of the connector state is still protected by
2336 	 * &drm_mode_config.mutex.
2337 	 */
2338 	struct mutex mutex;
2339 
2340 	/**
2341 	 * @index: Compacted connector index, which matches the position inside
2342 	 * the mode_config.list for drivers not supporting hot-add/removing. Can
2343 	 * be used as an array index. It is invariant over the lifetime of the
2344 	 * connector.
2345 	 */
2346 	unsigned index;
2347 
2348 	/**
2349 	 * @connector_type:
2350 	 * one of the DRM_MODE_CONNECTOR_<foo> types from drm_mode.h
2351 	 */
2352 	int connector_type;
2353 	/** @connector_type_id: index into connector type enum */
2354 	int connector_type_id;
2355 	/**
2356 	 * @interlace_allowed:
2357 	 * Can this connector handle interlaced modes? Only used by
2358 	 * drm_helper_probe_single_connector_modes() for mode filtering.
2359 	 */
2360 	bool interlace_allowed;
2361 	/**
2362 	 * @doublescan_allowed:
2363 	 * Can this connector handle doublescan? Only used by
2364 	 * drm_helper_probe_single_connector_modes() for mode filtering.
2365 	 */
2366 	bool doublescan_allowed;
2367 	/**
2368 	 * @stereo_allowed:
2369 	 * Can this connector handle stereo modes? Only used by
2370 	 * drm_helper_probe_single_connector_modes() for mode filtering.
2371 	 */
2372 	bool stereo_allowed;
2373 
2374 	/**
2375 	 * @ycbcr_420_allowed : This bool indicates if this connector is
2376 	 * capable of handling YCBCR 420 output. While parsing the EDID
2377 	 * blocks it's very helpful to know if the source is capable of
2378 	 * handling YCBCR 420 outputs.
2379 	 */
2380 	bool ycbcr_420_allowed;
2381 
2382 	/**
2383 	 * @registration_state: Is this connector initializing, exposed
2384 	 * (registered) with userspace, or unregistered?
2385 	 *
2386 	 * Protected by @mutex.
2387 	 */
2388 	enum drm_connector_registration_state registration_state;
2389 
2390 	/**
2391 	 * @modes:
2392 	 * Modes available on this connector (from fill_modes() + user).
2393 	 * Protected by &drm_mode_config.mutex.
2394 	 */
2395 	struct list_head modes;
2396 
2397 	/**
2398 	 * @status:
2399 	 * One of the drm_connector_status enums (connected, not, or unknown).
2400 	 * Protected by &drm_mode_config.mutex.
2401 	 */
2402 	enum drm_connector_status status;
2403 
2404 	/**
2405 	 * @probed_modes:
2406 	 * These are modes added by probing with DDC or the BIOS, before
2407 	 * filtering is applied. Used by the probe helpers. Protected by
2408 	 * &drm_mode_config.mutex.
2409 	 */
2410 	struct list_head probed_modes;
2411 
2412 	/**
2413 	 * @display_info: Display information is filled from EDID information
2414 	 * when a display is detected. For non hot-pluggable displays such as
2415 	 * flat panels in embedded systems, the driver should initialize the
2416 	 * &drm_display_info.width_mm and &drm_display_info.height_mm fields
2417 	 * with the physical size of the display.
2418 	 *
2419 	 * Protected by &drm_mode_config.mutex.
2420 	 */
2421 	struct drm_display_info display_info;
2422 
2423 	/** @funcs: connector control functions */
2424 	const struct drm_connector_funcs *funcs;
2425 
2426 	/**
2427 	 * @edid_blob_ptr: DRM property containing EDID if present. Protected by
2428 	 * &drm_mode_config.mutex.
2429 	 *
2430 	 * This must be updated only by calling drm_edid_connector_update() or
2431 	 * drm_connector_update_edid_property().
2432 	 *
2433 	 * This must not be used by drivers directly.
2434 	 */
2435 	struct drm_property_blob *edid_blob_ptr;
2436 
2437 	/** @properties: property tracking for this connector */
2438 	struct drm_object_properties properties;
2439 
2440 	/**
2441 	 * @scaling_mode_property: Optional atomic property to control the
2442 	 * upscaling. See drm_connector_attach_content_protection_property().
2443 	 */
2444 	struct drm_property *scaling_mode_property;
2445 
2446 	/**
2447 	 * @vrr_capable_property: Optional property to help userspace
2448 	 * query hardware support for variable refresh rate on a connector.
2449 	 * connector. Drivers can add the property to a connector by
2450 	 * calling drm_connector_attach_vrr_capable_property().
2451 	 *
2452 	 * This should be updated only by calling
2453 	 * drm_connector_set_vrr_capable_property().
2454 	 */
2455 	struct drm_property *vrr_capable_property;
2456 
2457 	/**
2458 	 * @colorspace_property: Connector property to set the suitable
2459 	 * colorspace supported by the sink.
2460 	 */
2461 	struct drm_property *colorspace_property;
2462 
2463 	/**
2464 	 * @color_format_property: Connector property to set the suitable
2465 	 * color format supported by the sink.
2466 	 */
2467 	struct drm_property *color_format_property;
2468 
2469 	/**
2470 	 * @path_blob_ptr:
2471 	 *
2472 	 * DRM blob property data for the DP MST path property. This should only
2473 	 * be updated by calling drm_connector_set_path_property().
2474 	 */
2475 	struct drm_property_blob *path_blob_ptr;
2476 
2477 	/**
2478 	 * @max_bpc: Maximum bits per color channel the connector supports.
2479 	 */
2480 	unsigned int max_bpc;
2481 
2482 	/**
2483 	 * @max_bpc_property: Default connector property for the max bpc to be
2484 	 * driven out of the connector.
2485 	 */
2486 	struct drm_property *max_bpc_property;
2487 
2488 	/** @privacy_screen: drm_privacy_screen for this connector, or NULL. */
2489 	struct drm_privacy_screen *privacy_screen;
2490 
2491 	/** @privacy_screen_notifier: privacy-screen notifier_block */
2492 	struct notifier_block privacy_screen_notifier;
2493 
2494 	/**
2495 	 * @privacy_screen_sw_state_property: Optional atomic property for the
2496 	 * connector to control the integrated privacy screen.
2497 	 */
2498 	struct drm_property *privacy_screen_sw_state_property;
2499 
2500 	/**
2501 	 * @privacy_screen_hw_state_property: Optional atomic property for the
2502 	 * connector to report the actual integrated privacy screen state.
2503 	 */
2504 	struct drm_property *privacy_screen_hw_state_property;
2505 
2506 	/**
2507 	 * @broadcast_rgb_property: Connector property to set the
2508 	 * Broadcast RGB selection to output with.
2509 	 */
2510 	struct drm_property *broadcast_rgb_property;
2511 
2512 #define DRM_CONNECTOR_POLL_HPD (1 << 0)
2513 #define DRM_CONNECTOR_POLL_CONNECT (1 << 1)
2514 #define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2)
2515 
2516 	/**
2517 	 * @polled:
2518 	 *
2519 	 * Connector polling mode, a combination of
2520 	 *
2521 	 * DRM_CONNECTOR_POLL_HPD
2522 	 *     The connector generates hotplug events and doesn't need to be
2523 	 *     periodically polled. The CONNECT and DISCONNECT flags must not
2524 	 *     be set together with the HPD flag.
2525 	 *
2526 	 * DRM_CONNECTOR_POLL_CONNECT
2527 	 *     Periodically poll the connector for connection.
2528 	 *
2529 	 * DRM_CONNECTOR_POLL_DISCONNECT
2530 	 *     Periodically poll the connector for disconnection, without
2531 	 *     causing flickering even when the connector is in use. DACs should
2532 	 *     rarely do this without a lot of testing.
2533 	 *
2534 	 * Set to 0 for connectors that don't support connection status
2535 	 * discovery.
2536 	 */
2537 	uint8_t polled;
2538 
2539 	/**
2540 	 * @dpms: Current dpms state. For legacy drivers the
2541 	 * &drm_connector_funcs.dpms callback must update this. For atomic
2542 	 * drivers, this is handled by the core atomic code, and drivers must
2543 	 * only take &drm_crtc_state.active into account.
2544 	 */
2545 	int dpms;
2546 
2547 	/** @helper_private: mid-layer private data */
2548 	const struct drm_connector_helper_funcs *helper_private;
2549 
2550 	/** @cmdline_mode: mode line parsed from the kernel cmdline for this connector */
2551 	struct drm_cmdline_mode cmdline_mode;
2552 	/** @force: a DRM_FORCE_<foo> state for forced mode sets */
2553 	enum drm_connector_force force;
2554 
2555 	/**
2556 	 * @edid_override: Override EDID set via debugfs.
2557 	 *
2558 	 * Do not modify or access outside of the drm_edid_override_* family of
2559 	 * functions.
2560 	 */
2561 	const struct drm_edid *edid_override;
2562 
2563 	/**
2564 	 * @edid_override_mutex: Protect access to edid_override.
2565 	 */
2566 	struct mutex edid_override_mutex;
2567 
2568 	/**
2569 	 * @epoch_counter: Used to detect changes in connector. Increased when
2570 	 * the connector, including its status, is changed.
2571 	 */
2572 	u64 epoch_counter;
2573 
2574 	/**
2575 	 * @possible_encoders: Bit mask of encoders that can drive this
2576 	 * connector, drm_encoder_index() determines the index into the bitfield
2577 	 * and the bits are set with drm_connector_attach_encoder().
2578 	 */
2579 	u32 possible_encoders;
2580 
2581 	/**
2582 	 * @encoder: Currently bound encoder driving this connector, if any.
2583 	 * Only really meaningful for non-atomic drivers. Atomic drivers should
2584 	 * instead look at &drm_connector_state.best_encoder, and in case they
2585 	 * need the CRTC driving this output, &drm_connector_state.crtc.
2586 	 */
2587 	struct drm_encoder *encoder;
2588 
2589 #define MAX_ELD_BYTES	128
2590 	/** @eld: EDID-like data, if present, protected by @eld_mutex */
2591 	uint8_t eld[MAX_ELD_BYTES];
2592 	/** @eld_mutex: protection for concurrenct access to @eld */
2593 	struct mutex eld_mutex;
2594 
2595 	/** @latency_present: AV delay info from ELD, if found */
2596 	bool latency_present[2];
2597 	/**
2598 	 * @video_latency: Video latency info from ELD, if found.
2599 	 * [0]: progressive, [1]: interlaced
2600 	 */
2601 	int video_latency[2];
2602 	/**
2603 	 * @audio_latency: audio latency info from ELD, if found
2604 	 * [0]: progressive, [1]: interlaced
2605 	 */
2606 	int audio_latency[2];
2607 
2608 	/**
2609 	 * @ddc: associated ddc adapter.
2610 	 * A connector usually has its associated ddc adapter. If a driver uses
2611 	 * this field, then an appropriate symbolic link is created in connector
2612 	 * sysfs directory to make it easy for the user to tell which i2c
2613 	 * adapter is for a particular display.
2614 	 *
2615 	 * The field should be set by calling drm_connector_init_with_ddc().
2616 	 */
2617 	struct i2c_adapter *ddc;
2618 
2619 	/**
2620 	 * @null_edid_counter: track sinks that give us all zeros for the EDID.
2621 	 * Needed to workaround some HW bugs where we get all 0s
2622 	 */
2623 	int null_edid_counter;
2624 
2625 	/** @bad_edid_counter: track sinks that give us an EDID with invalid checksum */
2626 	unsigned bad_edid_counter;
2627 
2628 	/**
2629 	 * @edid_corrupt: Indicates whether the last read EDID was corrupt. Used
2630 	 * in Displayport compliance testing - Displayport Link CTS Core 1.2
2631 	 * rev1.1 4.2.2.6
2632 	 */
2633 	bool edid_corrupt;
2634 	/**
2635 	 * @real_edid_checksum: real edid checksum for corrupted edid block.
2636 	 * Required in Displayport 1.4 compliance testing
2637 	 * rev1.1 4.2.2.6
2638 	 */
2639 	u8 real_edid_checksum;
2640 
2641 	/** @debugfs_entry: debugfs directory for this connector */
2642 	struct dentry *debugfs_entry;
2643 
2644 	/**
2645 	 * @state:
2646 	 *
2647 	 * Current atomic state for this connector.
2648 	 *
2649 	 * This is protected by &drm_mode_config.connection_mutex. Note that
2650 	 * nonblocking atomic commits access the current connector state without
2651 	 * taking locks. Either by going through the &struct drm_atomic_commit
2652 	 * pointers, see for_each_oldnew_connector_in_state(),
2653 	 * for_each_old_connector_in_state() and
2654 	 * for_each_new_connector_in_state(). Or through careful ordering of
2655 	 * atomic commit operations as implemented in the atomic helpers, see
2656 	 * &struct drm_crtc_commit.
2657 	 */
2658 	struct drm_connector_state *state;
2659 
2660 	/* DisplayID bits. FIXME: Extract into a substruct? */
2661 
2662 	/**
2663 	 * @tile_blob_ptr:
2664 	 *
2665 	 * DRM blob property data for the tile property (used mostly by DP MST).
2666 	 * This is meant for screens which are driven through separate display
2667 	 * pipelines represented by &drm_crtc, which might not be running with
2668 	 * genlocked clocks. For tiled panels which are genlocked, like
2669 	 * dual-link LVDS or dual-link DSI, the driver should try to not expose
2670 	 * the tiling and virtualize both &drm_crtc and &drm_plane if needed.
2671 	 *
2672 	 * This should only be updated by calling
2673 	 * drm_connector_set_tile_property().
2674 	 */
2675 	struct drm_property_blob *tile_blob_ptr;
2676 
2677 	/** @has_tile: is this connector connected to a tiled monitor */
2678 	bool has_tile;
2679 	/** @tile_group: tile group for the connected monitor */
2680 	struct drm_tile_group *tile_group;
2681 	/** @tile_is_single_monitor: whether the tile is one monitor housing */
2682 	bool tile_is_single_monitor;
2683 
2684 	/** @num_h_tile: number of horizontal tiles in the tile group */
2685 	/** @num_v_tile: number of vertical tiles in the tile group */
2686 	uint8_t num_h_tile, num_v_tile;
2687 	/** @tile_h_loc: horizontal location of this tile */
2688 	/** @tile_v_loc: vertical location of this tile */
2689 	uint8_t tile_h_loc, tile_v_loc;
2690 	/** @tile_h_size: horizontal size of this tile. */
2691 	/** @tile_v_size: vertical size of this tile. */
2692 	uint16_t tile_h_size, tile_v_size;
2693 
2694 	/**
2695 	 * @free_node:
2696 	 *
2697 	 * List used only by &drm_connector_list_iter to be able to clean up a
2698 	 * connector from any context, in conjunction with
2699 	 * &drm_mode_config.connector_free_work.
2700 	 */
2701 	struct llist_node free_node;
2702 
2703 	/**
2704 	 * @hdmi: HDMI-related variable and properties.
2705 	 */
2706 	struct drm_connector_hdmi hdmi;
2707 
2708 	/**
2709 	 * @hdmi_audio: HDMI codec properties and non-DRM state.
2710 	 */
2711 	struct drm_connector_hdmi_audio hdmi_audio;
2712 
2713 	/**
2714 	 * @cec: CEC-related data.
2715 	 */
2716 	struct drm_connector_cec cec;
2717 };
2718 
2719 #define obj_to_connector(x) container_of(x, struct drm_connector, base)
2720 
2721 int drm_connector_init(struct drm_device *dev,
2722 		       struct drm_connector *connector,
2723 		       const struct drm_connector_funcs *funcs,
2724 		       int connector_type);
2725 int drm_connector_dynamic_init(struct drm_device *dev,
2726 			       struct drm_connector *connector,
2727 			       const struct drm_connector_funcs *funcs,
2728 			       int connector_type,
2729 			       struct i2c_adapter *ddc);
2730 int drm_connector_init_with_ddc(struct drm_device *dev,
2731 				struct drm_connector *connector,
2732 				const struct drm_connector_funcs *funcs,
2733 				int connector_type,
2734 				struct i2c_adapter *ddc);
2735 int drmm_connector_init(struct drm_device *dev,
2736 			struct drm_connector *connector,
2737 			const struct drm_connector_funcs *funcs,
2738 			int connector_type,
2739 			struct i2c_adapter *ddc);
2740 int drmm_connector_hdmi_init(struct drm_device *dev,
2741 			     struct drm_connector *connector,
2742 			     const struct drm_connector_funcs *funcs,
2743 			     const struct drm_connector_hdmi_funcs *hdmi_funcs,
2744 			     int connector_type,
2745 			     struct i2c_adapter *ddc);
2746 int drmm_connector_hdmi_ini2(struct drm_device *dev,
2747 			     struct drm_connector *connector,
2748 			     const char *vendor, const char *product,
2749 			     const struct drm_connector_funcs *funcs,
2750 			     const struct drm_connector_hdmi_funcs *hdmi_funcs,
2751 			     int connector_type,
2752 			     struct i2c_adapter *ddc,
2753 			     unsigned long supported_formats,
2754 			     unsigned int max_bpc);
2755 void drm_connector_attach_edid_property(struct drm_connector *connector);
2756 int drm_connector_register(struct drm_connector *connector);
2757 int drm_connector_dynamic_register(struct drm_connector *connector);
2758 void drm_connector_unregister(struct drm_connector *connector);
2759 int drm_connector_attach_encoder(struct drm_connector *connector,
2760 				      struct drm_encoder *encoder);
2761 
2762 void drm_connector_cleanup(struct drm_connector *connector);
2763 
2764 static inline unsigned int drm_connector_index(const struct drm_connector *connector)
2765 {
2766 	return connector->index;
2767 }
2768 
2769 static inline u32 drm_connector_mask(const struct drm_connector *connector)
2770 {
2771 	return 1 << connector->index;
2772 }
2773 
2774 /**
2775  * drm_connector_lookup - lookup connector object
2776  * @dev: DRM device
2777  * @file_priv: drm file to check for lease against.
2778  * @id: connector object id
2779  *
2780  * This function looks up the connector object specified by id
2781  * add takes a reference to it.
2782  */
2783 static inline struct drm_connector *drm_connector_lookup(struct drm_device *dev,
2784 		struct drm_file *file_priv,
2785 		uint32_t id)
2786 {
2787 	struct drm_mode_object *mo;
2788 	mo = drm_mode_object_find(dev, file_priv, id, DRM_MODE_OBJECT_CONNECTOR);
2789 	return mo ? obj_to_connector(mo) : NULL;
2790 }
2791 
2792 /**
2793  * drm_connector_get - acquire a connector reference
2794  * @connector: DRM connector
2795  *
2796  * This function increments the connector's refcount.
2797  */
2798 static inline void drm_connector_get(struct drm_connector *connector)
2799 {
2800 	drm_mode_object_get(&connector->base);
2801 }
2802 
2803 /**
2804  * drm_connector_put - release a connector reference
2805  * @connector: DRM connector
2806  *
2807  * This function decrements the connector's reference count and frees the
2808  * object if the reference count drops to zero.
2809  */
2810 static inline void drm_connector_put(struct drm_connector *connector)
2811 {
2812 	drm_mode_object_put(&connector->base);
2813 }
2814 
2815 /**
2816  * drm_connector_is_unregistered - has the connector been unregistered from
2817  * userspace?
2818  * @connector: DRM connector
2819  *
2820  * Checks whether or not @connector has been unregistered from userspace.
2821  *
2822  * Returns:
2823  * True if the connector was unregistered, false if the connector is
2824  * registered or has not yet been registered with userspace.
2825  */
2826 static inline bool
2827 drm_connector_is_unregistered(struct drm_connector *connector)
2828 {
2829 	return READ_ONCE(connector->registration_state) ==
2830 		DRM_CONNECTOR_UNREGISTERED;
2831 }
2832 
2833 /**
2834  * drm_connector_hdmi_scrambler_supported - does connector support HDMI
2835  * scrambling?
2836  * @connector: DRM connector
2837  *
2838  * Checks whether or not @connector driver supports HDMI scrambling, based on
2839  * the HDMI version advertised by the controller.
2840  *
2841  * Returns:
2842  * True if the connector supports scrambling, false otherwise.
2843  */
2844 static inline bool
2845 drm_connector_hdmi_scrambler_supported(const struct drm_connector *connector)
2846 {
2847 	return connector->hdmi.funcs &&
2848 		connector->hdmi.funcs->supported_hdmi_ver >= HDMI_VERSION_2_0;
2849 }
2850 
2851 void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode,
2852 				     enum drm_connector_status status);
2853 enum drm_connector_color_format
2854 drm_connector_get_color_format(const struct drm_connector_state *conn_state);
2855 const char *drm_get_connector_type_name(unsigned int connector_type);
2856 const char *drm_get_connector_status_name(enum drm_connector_status status);
2857 const char *drm_get_subpixel_order_name(enum subpixel_order order);
2858 const char *drm_get_dpms_name(int val);
2859 const char *drm_get_dvi_i_subconnector_name(int val);
2860 const char *drm_get_dvi_i_select_name(int val);
2861 const char *drm_get_tv_mode_name(int val);
2862 const char *drm_get_tv_subconnector_name(int val);
2863 const char *drm_get_tv_select_name(int val);
2864 const char *drm_get_dp_subconnector_name(int val);
2865 const char *drm_get_content_protection_name(int val);
2866 const char *drm_get_hdcp_content_type_name(int val);
2867 
2868 int drm_get_tv_mode_from_name(const char *name, size_t len);
2869 
2870 int drm_mode_create_dvi_i_properties(struct drm_device *dev);
2871 void drm_connector_attach_dp_subconnector_property(struct drm_connector *connector);
2872 
2873 int drm_mode_create_tv_margin_properties(struct drm_device *dev);
2874 int drm_mode_create_tv_properties_legacy(struct drm_device *dev,
2875 					 unsigned int num_modes,
2876 					 const char * const modes[]);
2877 int drm_mode_create_tv_properties(struct drm_device *dev,
2878 				  unsigned int supported_tv_modes);
2879 void drm_connector_attach_tv_margin_properties(struct drm_connector *conn);
2880 int drm_mode_create_scaling_mode_property(struct drm_device *dev);
2881 int drm_connector_attach_content_type_property(struct drm_connector *dev);
2882 int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,
2883 					       u32 scaling_mode_mask);
2884 int drm_connector_attach_vrr_capable_property(
2885 		struct drm_connector *connector);
2886 void drm_connector_attach_panel_type_property(struct drm_connector *connector);
2887 int drm_connector_attach_broadcast_rgb_property(struct drm_connector *connector);
2888 int drm_connector_attach_colorspace_property(struct drm_connector *connector);
2889 void drm_connector_attach_hdr_output_metadata_property(struct drm_connector *connector);
2890 bool drm_connector_atomic_hdr_metadata_equal(struct drm_connector_state *old_state,
2891 					     struct drm_connector_state *new_state);
2892 int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
2893 int drm_mode_create_hdmi_colorspace_property(struct drm_connector *connector,
2894 					     u32 supported_colorspaces);
2895 int drm_mode_create_dp_colorspace_property(struct drm_connector *connector,
2896 					   u32 supported_colorspaces);
2897 int drm_mode_create_content_type_property(struct drm_device *dev);
2898 int drm_mode_create_suggested_offset_properties(struct drm_device *dev);
2899 
2900 int drm_connector_set_path_property(struct drm_connector *connector,
2901 				    const char *path);
2902 int drm_connector_set_tile_property(struct drm_connector *connector);
2903 int drm_connector_update_edid_property(struct drm_connector *connector,
2904 				       const struct edid *edid);
2905 void drm_connector_set_link_status_property(struct drm_connector *connector,
2906 					    uint64_t link_status);
2907 void drm_connector_set_vrr_capable_property(
2908 		struct drm_connector *connector, bool capable);
2909 int drm_connector_set_panel_orientation(
2910 	struct drm_connector *connector,
2911 	enum drm_panel_orientation panel_orientation);
2912 int drm_connector_set_panel_orientation_with_quirk(
2913 	struct drm_connector *connector,
2914 	enum drm_panel_orientation panel_orientation,
2915 	int width, int height);
2916 int drm_connector_set_orientation_from_panel(
2917 	struct drm_connector *connector,
2918 	struct drm_panel *panel);
2919 int drm_connector_attach_max_bpc_property(struct drm_connector *connector,
2920 					  int min, int max);
2921 void drm_connector_create_privacy_screen_properties(struct drm_connector *conn);
2922 void drm_connector_attach_privacy_screen_properties(struct drm_connector *conn);
2923 void drm_connector_attach_privacy_screen_provider(
2924 	struct drm_connector *connector, struct drm_privacy_screen *priv);
2925 void drm_connector_update_privacy_screen(const struct drm_connector_state *connector_state);
2926 
2927 /**
2928  * struct drm_tile_group - Tile group metadata
2929  * @refcount: reference count
2930  * @dev: DRM device
2931  * @id: tile group id exposed to userspace
2932  * @group_data: Sink-private data identifying this group
2933  *
2934  * @group_data corresponds to displayid vend/prod/serial for external screens
2935  * with an EDID.
2936  */
2937 struct drm_tile_group {
2938 	struct kref refcount;
2939 	struct drm_device *dev;
2940 	int id;
2941 	u8 group_data[9];
2942 };
2943 
2944 struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
2945 						  const char topology_id[9]);
2946 struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
2947 					       const char topology_id[9]);
2948 void drm_mode_put_tile_group(struct drm_device *dev,
2949 			     struct drm_tile_group *tg);
2950 
2951 /**
2952  * struct drm_connector_list_iter - connector_list iterator
2953  *
2954  * This iterator tracks state needed to be able to walk the connector_list
2955  * within struct drm_mode_config. Only use together with
2956  * drm_connector_list_iter_begin(), drm_connector_list_iter_end() and
2957  * drm_connector_list_iter_next() respectively the convenience macro
2958  * drm_for_each_connector_iter().
2959  *
2960  * Note that the return value of drm_connector_list_iter_next() is only valid
2961  * up to the next drm_connector_list_iter_next() or
2962  * drm_connector_list_iter_end() call. If you want to use the connector later,
2963  * then you need to grab your own reference first using drm_connector_get().
2964  */
2965 struct drm_connector_list_iter {
2966 /* private: */
2967 	struct drm_device *dev;
2968 	struct drm_connector *conn;
2969 };
2970 
2971 void drm_connector_list_iter_begin(struct drm_device *dev,
2972 				   struct drm_connector_list_iter *iter);
2973 struct drm_connector *
2974 drm_connector_list_iter_next(struct drm_connector_list_iter *iter);
2975 void drm_connector_list_iter_end(struct drm_connector_list_iter *iter);
2976 
2977 bool drm_connector_has_possible_encoder(struct drm_connector *connector,
2978 					struct drm_encoder *encoder);
2979 const char *drm_get_colorspace_name(enum drm_colorspace colorspace);
2980 
2981 int drm_connector_attach_color_format_property(struct drm_connector *connector,
2982 					       unsigned long supported_color_formats);
2983 
2984 /**
2985  * drm_for_each_connector_iter - connector_list iterator macro
2986  * @connector: &struct drm_connector pointer used as cursor
2987  * @iter: &struct drm_connector_list_iter
2988  *
2989  * Note that @connector is only valid within the list body, if you want to use
2990  * @connector after calling drm_connector_list_iter_end() then you need to grab
2991  * your own reference first using drm_connector_get().
2992  */
2993 #define drm_for_each_connector_iter(connector, iter) \
2994 	while ((connector = drm_connector_list_iter_next(iter)))
2995 
2996 /**
2997  * drm_connector_for_each_possible_encoder - iterate connector's possible encoders
2998  * @connector: &struct drm_connector pointer
2999  * @encoder: &struct drm_encoder pointer used as cursor
3000  */
3001 #define drm_connector_for_each_possible_encoder(connector, encoder) \
3002 	drm_for_each_encoder_mask(encoder, (connector)->dev, \
3003 				  (connector)->possible_encoders)
3004 
3005 #endif
3006