xref: /OK3568_Linux_fs/kernel/include/drm/drm_connector.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
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 <drm/drm_mode_object.h>
31 #include <drm/drm_util.h>
32 
33 #include <uapi/drm/drm_mode.h>
34 
35 struct drm_connector_helper_funcs;
36 struct drm_modeset_acquire_ctx;
37 struct drm_device;
38 struct drm_crtc;
39 struct drm_encoder;
40 struct drm_property;
41 struct drm_property_blob;
42 struct drm_printer;
43 struct edid;
44 struct i2c_adapter;
45 
46 enum drm_connector_force {
47 	DRM_FORCE_UNSPECIFIED,
48 	DRM_FORCE_OFF,
49 	DRM_FORCE_ON,         /* force on analog part normally */
50 	DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */
51 };
52 
53 /**
54  * enum drm_connector_status - status for a &drm_connector
55  *
56  * This enum is used to track the connector status. There are no separate
57  * #defines for the uapi!
58  */
59 enum drm_connector_status {
60 	/**
61 	 * @connector_status_connected: The connector is definitely connected to
62 	 * a sink device, and can be enabled.
63 	 */
64 	connector_status_connected = 1,
65 	/**
66 	 * @connector_status_disconnected: The connector isn't connected to a
67 	 * sink device which can be autodetect. For digital outputs like DP or
68 	 * HDMI (which can be realiable probed) this means there's really
69 	 * nothing there. It is driver-dependent whether a connector with this
70 	 * status can be lit up or not.
71 	 */
72 	connector_status_disconnected = 2,
73 	/**
74 	 * @connector_status_unknown: The connector's status could not be
75 	 * reliably detected. This happens when probing would either cause
76 	 * flicker (like load-detection when the connector is in use), or when a
77 	 * hardware resource isn't available (like when load-detection needs a
78 	 * free CRTC). It should be possible to light up the connector with one
79 	 * of the listed fallback modes. For default configuration userspace
80 	 * should only try to light up connectors with unknown status when
81 	 * there's not connector with @connector_status_connected.
82 	 */
83 	connector_status_unknown = 3,
84 };
85 
86 /**
87  * enum drm_connector_registration_status - userspace registration status for
88  * a &drm_connector
89  *
90  * This enum is used to track the status of initializing a connector and
91  * registering it with userspace, so that DRM can prevent bogus modesets on
92  * connectors that no longer exist.
93  */
94 enum drm_connector_registration_state {
95 	/**
96 	 * @DRM_CONNECTOR_INITIALIZING: The connector has just been created,
97 	 * but has yet to be exposed to userspace. There should be no
98 	 * additional restrictions to how the state of this connector may be
99 	 * modified.
100 	 */
101 	DRM_CONNECTOR_INITIALIZING = 0,
102 
103 	/**
104 	 * @DRM_CONNECTOR_REGISTERED: The connector has been fully initialized
105 	 * and registered with sysfs, as such it has been exposed to
106 	 * userspace. There should be no additional restrictions to how the
107 	 * state of this connector may be modified.
108 	 */
109 	DRM_CONNECTOR_REGISTERED = 1,
110 
111 	/**
112 	 * @DRM_CONNECTOR_UNREGISTERED: The connector has either been exposed
113 	 * to userspace and has since been unregistered and removed from
114 	 * userspace, or the connector was unregistered before it had a chance
115 	 * to be exposed to userspace (e.g. still in the
116 	 * @DRM_CONNECTOR_INITIALIZING state). When a connector is
117 	 * unregistered, there are additional restrictions to how its state
118 	 * may be modified:
119 	 *
120 	 * - An unregistered connector may only have its DPMS changed from
121 	 *   On->Off. Once DPMS is changed to Off, it may not be switched back
122 	 *   to On.
123 	 * - Modesets are not allowed on unregistered connectors, unless they
124 	 *   would result in disabling its assigned CRTCs. This means
125 	 *   disabling a CRTC on an unregistered connector is OK, but enabling
126 	 *   one is not.
127 	 * - Removing a CRTC from an unregistered connector is OK, but new
128 	 *   CRTCs may never be assigned to an unregistered connector.
129 	 */
130 	DRM_CONNECTOR_UNREGISTERED = 2,
131 };
132 
133 enum subpixel_order {
134 	SubPixelUnknown = 0,
135 	SubPixelHorizontalRGB,
136 	SubPixelHorizontalBGR,
137 	SubPixelVerticalRGB,
138 	SubPixelVerticalBGR,
139 	SubPixelNone,
140 
141 };
142 
143 /**
144  * struct drm_scrambling: sink's scrambling support.
145  */
146 struct drm_scrambling {
147 	/**
148 	 * @supported: scrambling supported for rates > 340 Mhz.
149 	 */
150 	bool supported;
151 	/**
152 	 * @low_rates: scrambling supported for rates <= 340 Mhz.
153 	 */
154 	bool low_rates;
155 };
156 
157 /*
158  * struct drm_scdc - Information about scdc capabilities of a HDMI 2.0 sink
159  *
160  * Provides SCDC register support and capabilities related information on a
161  * HDMI 2.0 sink. In case of a HDMI 1.4 sink, all parameter must be 0.
162  */
163 struct drm_scdc {
164 	/**
165 	 * @supported: status control & data channel present.
166 	 */
167 	bool supported;
168 	/**
169 	 * @read_request: sink is capable of generating scdc read request.
170 	 */
171 	bool read_request;
172 	/**
173 	 * @scrambling: sink's scrambling capabilities
174 	 */
175 	struct drm_scrambling scrambling;
176 };
177 
178 #ifdef CONFIG_NO_GKI
179 /**
180  * struct drm_hdmi_dsc_cap - DSC capabilities of HDMI sink
181  *
182  * Describes the DSC support provided by HDMI 2.1 sink.
183  * The information is fetched fom additional HFVSDB blocks defined
184  * for HDMI 2.1.
185  */
186 struct drm_hdmi_dsc_cap {
187 	/** @v_1p2: flag for dsc1.2 version support by sink */
188 	bool v_1p2;
189 
190 	/** @native_420: Does sink support DSC with 4:2:0 compression */
191 	bool native_420;
192 
193 	/**
194 	 * @all_bpp: Does sink support all bpp with 4:4:4: or 4:2:2
195 	 * compressed formats
196 	 */
197 	bool all_bpp;
198 
199 	/**
200 	 * @bpc_supported: compressed bpc supported by sink : 10, 12 or 16 bpc
201 	 */
202 	u8 bpc_supported;
203 
204 	/** @max_slices: maximum number of Horizontal slices supported by */
205 	u8 max_slices;
206 
207 	/** @clk_per_slice : max pixel clock in MHz supported per slice */
208 	int clk_per_slice;
209 
210 	/** @max_lanes : dsc max lanes supported for Fixed rate Link training */
211 	u8 max_lanes;
212 
213 	/** @max_frl_rate_per_lane : maximum frl rate with DSC per lane */
214 	u8 max_frl_rate_per_lane;
215 
216 	/** @total_chunk_kbytes: max size of chunks in KBs supported per line*/
217 	u8 total_chunk_kbytes;
218 };
219 #endif
220 
221 /**
222  * struct drm_hdmi_info - runtime information about the connected HDMI sink
223  *
224  * Describes if a given display supports advanced HDMI 2.0 features.
225  * This information is available in CEA-861-F extension blocks (like HF-VSDB).
226  */
227 struct drm_hdmi_info {
228 	/** @scdc: sink's scdc support and capabilities */
229 	struct drm_scdc scdc;
230 
231 	/**
232 	 * @y420_vdb_modes: bitmap of modes which can support ycbcr420
233 	 * output only (not normal RGB/YCBCR444/422 outputs). The max VIC
234 	 * defined by the CEA-861-G spec is 219, so the size is 256 bits to map
235 	 * up to 256 VICs.
236 	 */
237 	unsigned long y420_vdb_modes[BITS_TO_LONGS(256)];
238 
239 	/**
240 	 * @y420_cmdb_modes: bitmap of modes which can support ycbcr420
241 	 * output also, along with normal HDMI outputs. The max VIC defined by
242 	 * the CEA-861-G spec is 219, so the size is 256 bits to map up to 256
243 	 * VICs.
244 	 */
245 	unsigned long y420_cmdb_modes[BITS_TO_LONGS(256)];
246 
247 	/** @y420_cmdb_map: bitmap of SVD index, to extraxt vcb modes */
248 	u64 y420_cmdb_map;
249 
250 	/** @y420_dc_modes: bitmap of deep color support index */
251 	u8 y420_dc_modes;
252 
253 #ifdef CONFIG_NO_GKI
254 	/** @max_frl_rate_per_lane: support fixed rate link */
255 	u8 max_frl_rate_per_lane;
256 
257 	/** @max_lanes: supported by sink */
258 	u8 max_lanes;
259 
260 	/** @dsc_cap: DSC capabilities of the sink */
261 	struct drm_hdmi_dsc_cap dsc_cap;
262 #endif
263 };
264 
265 /**
266  * enum drm_link_status - connector's link_status property value
267  *
268  * This enum is used as the connector's link status property value.
269  * It is set to the values defined in uapi.
270  *
271  * @DRM_LINK_STATUS_GOOD: DP Link is Good as a result of successful
272  *                        link training
273  * @DRM_LINK_STATUS_BAD: DP Link is BAD as a result of link training
274  *                       failure
275  */
276 enum drm_link_status {
277 	DRM_LINK_STATUS_GOOD = DRM_MODE_LINK_STATUS_GOOD,
278 	DRM_LINK_STATUS_BAD = DRM_MODE_LINK_STATUS_BAD,
279 };
280 
281 /**
282  * enum drm_panel_orientation - panel_orientation info for &drm_display_info
283  *
284  * This enum is used to track the (LCD) panel orientation. There are no
285  * separate #defines for the uapi!
286  *
287  * @DRM_MODE_PANEL_ORIENTATION_UNKNOWN: The drm driver has not provided any
288  *					panel orientation information (normal
289  *					for non panels) in this case the "panel
290  *					orientation" connector prop will not be
291  *					attached.
292  * @DRM_MODE_PANEL_ORIENTATION_NORMAL:	The top side of the panel matches the
293  *					top side of the device's casing.
294  * @DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP: The top side of the panel matches the
295  *					bottom side of the device's casing, iow
296  *					the panel is mounted upside-down.
297  * @DRM_MODE_PANEL_ORIENTATION_LEFT_UP:	The left side of the panel matches the
298  *					top side of the device's casing.
299  * @DRM_MODE_PANEL_ORIENTATION_RIGHT_UP: The right side of the panel matches the
300  *					top side of the device's casing.
301  */
302 enum drm_panel_orientation {
303 	DRM_MODE_PANEL_ORIENTATION_UNKNOWN = -1,
304 	DRM_MODE_PANEL_ORIENTATION_NORMAL = 0,
305 	DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP,
306 	DRM_MODE_PANEL_ORIENTATION_LEFT_UP,
307 	DRM_MODE_PANEL_ORIENTATION_RIGHT_UP,
308 };
309 
310 /**
311  * struct drm_monitor_range_info - Panel's Monitor range in EDID for
312  * &drm_display_info
313  *
314  * This struct is used to store a frequency range supported by panel
315  * as parsed from EDID's detailed monitor range descriptor block.
316  *
317  * @min_vfreq: This is the min supported refresh rate in Hz from
318  *             EDID's detailed monitor range.
319  * @max_vfreq: This is the max supported refresh rate in Hz from
320  *             EDID's detailed monitor range
321  */
322 struct drm_monitor_range_info {
323 	u8 min_vfreq;
324 	u8 max_vfreq;
325 };
326 
327 /*
328  * This is a consolidated colorimetry list supported by HDMI and
329  * DP protocol standard. The respective connectors will register
330  * a property with the subset of this list (supported by that
331  * respective protocol). Userspace will set the colorspace through
332  * a colorspace property which will be created and exposed to
333  * userspace.
334  */
335 
336 /* For Default case, driver will set the colorspace */
337 #define DRM_MODE_COLORIMETRY_DEFAULT			0
338 /* CEA 861 Normal Colorimetry options */
339 #define DRM_MODE_COLORIMETRY_NO_DATA			0
340 #define DRM_MODE_COLORIMETRY_SMPTE_170M_YCC		1
341 #define DRM_MODE_COLORIMETRY_BT709_YCC			2
342 /* CEA 861 Extended Colorimetry Options */
343 #define DRM_MODE_COLORIMETRY_XVYCC_601			3
344 #define DRM_MODE_COLORIMETRY_XVYCC_709			4
345 #define DRM_MODE_COLORIMETRY_SYCC_601			5
346 #define DRM_MODE_COLORIMETRY_OPYCC_601			6
347 #define DRM_MODE_COLORIMETRY_OPRGB			7
348 #define DRM_MODE_COLORIMETRY_BT2020_CYCC		8
349 #define DRM_MODE_COLORIMETRY_BT2020_RGB			9
350 #define DRM_MODE_COLORIMETRY_BT2020_YCC			10
351 /* Additional Colorimetry extension added as part of CTA 861.G */
352 #define DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65		11
353 #define DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER		12
354 /* Additional Colorimetry Options added for DP 1.4a VSC Colorimetry Format */
355 #define DRM_MODE_COLORIMETRY_RGB_WIDE_FIXED		13
356 #define DRM_MODE_COLORIMETRY_RGB_WIDE_FLOAT		14
357 #define DRM_MODE_COLORIMETRY_BT601_YCC			15
358 
359 /**
360  * enum drm_bus_flags - bus_flags info for &drm_display_info
361  *
362  * This enum defines signal polarities and clock edge information for signals on
363  * a bus as bitmask flags.
364  *
365  * The clock edge information is conveyed by two sets of symbols,
366  * DRM_BUS_FLAGS_*_DRIVE_\* and DRM_BUS_FLAGS_*_SAMPLE_\*. When this enum is
367  * used to describe a bus from the point of view of the transmitter, the
368  * \*_DRIVE_\* flags should be used. When used from the point of view of the
369  * receiver, the \*_SAMPLE_\* flags should be used. The \*_DRIVE_\* and
370  * \*_SAMPLE_\* flags alias each other, with the \*_SAMPLE_POSEDGE and
371  * \*_SAMPLE_NEGEDGE flags being equal to \*_DRIVE_NEGEDGE and \*_DRIVE_POSEDGE
372  * respectively. This simplifies code as signals are usually sampled on the
373  * opposite edge of the driving edge. Transmitters and receivers may however
374  * need to take other signal timings into account to convert between driving
375  * and sample edges.
376  */
377 enum drm_bus_flags {
378 	/**
379 	 * @DRM_BUS_FLAG_DE_LOW:
380 	 *
381 	 * The Data Enable signal is active low
382 	 */
383 	DRM_BUS_FLAG_DE_LOW = BIT(0),
384 
385 	/**
386 	 * @DRM_BUS_FLAG_DE_HIGH:
387 	 *
388 	 * The Data Enable signal is active high
389 	 */
390 	DRM_BUS_FLAG_DE_HIGH = BIT(1),
391 
392 	/**
393 	 * @DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE:
394 	 *
395 	 * Data is driven on the rising edge of the pixel clock
396 	 */
397 	DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE = BIT(2),
398 
399 	/**
400 	 * @DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE:
401 	 *
402 	 * Data is driven on the falling edge of the pixel clock
403 	 */
404 	DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE = BIT(3),
405 
406 	/**
407 	 * @DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE:
408 	 *
409 	 * Data is sampled on the rising edge of the pixel clock
410 	 */
411 	DRM_BUS_FLAG_PIXDATA_SAMPLE_POSEDGE = DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE,
412 
413 	/**
414 	 * @DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE:
415 	 *
416 	 * Data is sampled on the falling edge of the pixel clock
417 	 */
418 	DRM_BUS_FLAG_PIXDATA_SAMPLE_NEGEDGE = DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE,
419 
420 	/**
421 	 * @DRM_BUS_FLAG_DATA_MSB_TO_LSB:
422 	 *
423 	 * Data is transmitted MSB to LSB on the bus
424 	 */
425 	DRM_BUS_FLAG_DATA_MSB_TO_LSB = BIT(4),
426 
427 	/**
428 	 * @DRM_BUS_FLAG_DATA_LSB_TO_MSB:
429 	 *
430 	 * Data is transmitted LSB to MSB on the bus
431 	 */
432 	DRM_BUS_FLAG_DATA_LSB_TO_MSB = BIT(5),
433 
434 	/**
435 	 * @DRM_BUS_FLAG_SYNC_DRIVE_POSEDGE:
436 	 *
437 	 * Sync signals are driven on the rising edge of the pixel clock
438 	 */
439 	DRM_BUS_FLAG_SYNC_DRIVE_POSEDGE = BIT(6),
440 
441 	/**
442 	 * @DRM_BUS_FLAG_SYNC_DRIVE_NEGEDGE:
443 	 *
444 	 * Sync signals are driven on the falling edge of the pixel clock
445 	 */
446 	DRM_BUS_FLAG_SYNC_DRIVE_NEGEDGE = BIT(7),
447 
448 	/**
449 	 * @DRM_BUS_FLAG_SYNC_SAMPLE_POSEDGE:
450 	 *
451 	 * Sync signals are sampled on the rising edge of the pixel clock
452 	 */
453 	DRM_BUS_FLAG_SYNC_SAMPLE_POSEDGE = DRM_BUS_FLAG_SYNC_DRIVE_NEGEDGE,
454 
455 	/**
456 	 * @DRM_BUS_FLAG_SYNC_SAMPLE_NEGEDGE:
457 	 *
458 	 * Sync signals are sampled on the falling edge of the pixel clock
459 	 */
460 	DRM_BUS_FLAG_SYNC_SAMPLE_NEGEDGE = DRM_BUS_FLAG_SYNC_DRIVE_POSEDGE,
461 
462 	/**
463 	 * @DRM_BUS_FLAG_SHARP_SIGNALS:
464 	 *
465 	 *  Set if the Sharp-specific signals (SPL, CLS, PS, REV) must be used
466 	 */
467 	DRM_BUS_FLAG_SHARP_SIGNALS = BIT(8),
468 };
469 
470 /**
471  * struct drm_display_info - runtime data about the connected sink
472  *
473  * Describes a given display (e.g. CRT or flat panel) and its limitations. For
474  * fixed display sinks like built-in panels there's not much difference between
475  * this and &struct drm_connector. But for sinks with a real cable this
476  * structure is meant to describe all the things at the other end of the cable.
477  *
478  * For sinks which provide an EDID this can be filled out by calling
479  * drm_add_edid_modes().
480  */
481 struct drm_display_info {
482 	/**
483 	 * @width_mm: Physical width in mm.
484 	 */
485 	unsigned int width_mm;
486 
487 	/**
488 	 * @height_mm: Physical height in mm.
489 	 */
490 	unsigned int height_mm;
491 
492 	/**
493 	 * @bpc: Maximum bits per color channel. Used by HDMI and DP outputs.
494 	 */
495 	unsigned int bpc;
496 
497 	/**
498 	 * @subpixel_order: Subpixel order of LCD panels.
499 	 */
500 	enum subpixel_order subpixel_order;
501 
502 #define DRM_COLOR_FORMAT_RGB444		(1<<0)
503 #define DRM_COLOR_FORMAT_YCRCB444	(1<<1)
504 #define DRM_COLOR_FORMAT_YCRCB422	(1<<2)
505 #define DRM_COLOR_FORMAT_YCRCB420	(1<<3)
506 
507 	/**
508 	 * @panel_orientation: Read only connector property for built-in panels,
509 	 * indicating the orientation of the panel vs the device's casing.
510 	 * drm_connector_init() sets this to DRM_MODE_PANEL_ORIENTATION_UNKNOWN.
511 	 * When not UNKNOWN this gets used by the drm_fb_helpers to rotate the
512 	 * fb to compensate and gets exported as prop to userspace.
513 	 */
514 	int panel_orientation;
515 
516 	/**
517 	 * @color_formats: HDMI Color formats, selects between RGB and YCrCb
518 	 * modes. Used DRM_COLOR_FORMAT\_ defines, which are _not_ the same ones
519 	 * as used to describe the pixel format in framebuffers, and also don't
520 	 * match the formats in @bus_formats which are shared with v4l.
521 	 */
522 	u32 color_formats;
523 
524 	/**
525 	 * @bus_formats: Pixel data format on the wire, somewhat redundant with
526 	 * @color_formats. Array of size @num_bus_formats encoded using
527 	 * MEDIA_BUS_FMT\_ defines shared with v4l and media drivers.
528 	 */
529 	const u32 *bus_formats;
530 	/**
531 	 * @num_bus_formats: Size of @bus_formats array.
532 	 */
533 	unsigned int num_bus_formats;
534 
535 	/**
536 	 * @bus_flags: Additional information (like pixel signal polarity) for
537 	 * the pixel data on the bus, using &enum drm_bus_flags values
538 	 * DRM_BUS_FLAGS\_.
539 	 */
540 	u32 bus_flags;
541 
542 	/**
543 	 * @max_tmds_clock: Maximum TMDS clock rate supported by the
544 	 * sink in kHz. 0 means undefined.
545 	 */
546 	int max_tmds_clock;
547 
548 	/**
549 	 * @dvi_dual: Dual-link DVI sink?
550 	 */
551 	bool dvi_dual;
552 
553 	/**
554 	 * @is_hdmi: True if the sink is an HDMI device.
555 	 *
556 	 * This field shall be used instead of calling
557 	 * drm_detect_hdmi_monitor() when possible.
558 	 */
559 	bool is_hdmi;
560 
561 	/**
562 	 * @has_hdmi_infoframe: Does the sink support the HDMI infoframe?
563 	 */
564 	bool has_hdmi_infoframe;
565 
566 	/**
567 	 * @rgb_quant_range_selectable: Does the sink support selecting
568 	 * the RGB quantization range?
569 	 */
570 	bool rgb_quant_range_selectable;
571 
572 	/**
573 	 * @edid_hdmi_dc_modes: Mask of supported hdmi deep color modes. Even
574 	 * more stuff redundant with @bus_formats.
575 	 */
576 	u8 edid_hdmi_dc_modes;
577 
578 	/**
579 	 * @cea_rev: CEA revision of the HDMI sink.
580 	 */
581 	u8 cea_rev;
582 
583 	/**
584 	 * @hdmi: advance features of a HDMI sink.
585 	 */
586 	struct drm_hdmi_info hdmi;
587 
588 	/**
589 	 * @non_desktop: Non desktop display (HMD).
590 	 */
591 	bool non_desktop;
592 
593 	/**
594 	 * @monitor_range: Frequency range supported by monitor range descriptor
595 	 */
596 	struct drm_monitor_range_info monitor_range;
597 };
598 
599 int drm_display_info_set_bus_formats(struct drm_display_info *info,
600 				     const u32 *formats,
601 				     unsigned int num_formats);
602 
603 /**
604  * struct drm_connector_tv_margins - TV connector related margins
605  *
606  * Describes the margins in pixels to put around the image on TV
607  * connectors to deal with overscan.
608  */
609 struct drm_connector_tv_margins {
610 	/**
611 	 * @bottom: Bottom margin in pixels.
612 	 */
613 	unsigned int bottom;
614 
615 	/**
616 	 * @left: Left margin in pixels.
617 	 */
618 	unsigned int left;
619 
620 	/**
621 	 * @right: Right margin in pixels.
622 	 */
623 	unsigned int right;
624 
625 	/**
626 	 * @top: Top margin in pixels.
627 	 */
628 	unsigned int top;
629 };
630 
631 /**
632  * struct drm_tv_connector_state - TV connector related states
633  * @subconnector: selected subconnector
634  * @margins: TV margins
635  * @mode: TV mode
636  * @brightness: brightness in percent
637  * @contrast: contrast in percent
638  * @flicker_reduction: flicker reduction in percent
639  * @overscan: overscan in percent
640  * @saturation: saturation in percent
641  * @hue: hue in percent
642  */
643 struct drm_tv_connector_state {
644 	enum drm_mode_subconnector subconnector;
645 	struct drm_connector_tv_margins margins;
646 	unsigned int mode;
647 	unsigned int brightness;
648 	unsigned int contrast;
649 	unsigned int flicker_reduction;
650 	unsigned int overscan;
651 	unsigned int saturation;
652 	unsigned int hue;
653 };
654 
655 /**
656  * struct drm_connector_state - mutable connector state
657  */
658 struct drm_connector_state {
659 	/** @connector: backpointer to the connector */
660 	struct drm_connector *connector;
661 
662 	/**
663 	 * @crtc: CRTC to connect connector to, NULL if disabled.
664 	 *
665 	 * Do not change this directly, use drm_atomic_set_crtc_for_connector()
666 	 * instead.
667 	 */
668 	struct drm_crtc *crtc;
669 
670 	/**
671 	 * @best_encoder:
672 	 *
673 	 * Used by the atomic helpers to select the encoder, through the
674 	 * &drm_connector_helper_funcs.atomic_best_encoder or
675 	 * &drm_connector_helper_funcs.best_encoder callbacks.
676 	 *
677 	 * This is also used in the atomic helpers to map encoders to their
678 	 * current and previous connectors, see
679 	 * drm_atomic_get_old_connector_for_encoder() and
680 	 * drm_atomic_get_new_connector_for_encoder().
681 	 *
682 	 * NOTE: Atomic drivers must fill this out (either themselves or through
683 	 * helpers), for otherwise the GETCONNECTOR and GETENCODER IOCTLs will
684 	 * not return correct data to userspace.
685 	 */
686 	struct drm_encoder *best_encoder;
687 
688 	/**
689 	 * @link_status: Connector link_status to keep track of whether link is
690 	 * GOOD or BAD to notify userspace if retraining is necessary.
691 	 */
692 	enum drm_link_status link_status;
693 
694 	/** @state: backpointer to global drm_atomic_state */
695 	struct drm_atomic_state *state;
696 
697 	/**
698 	 * @commit: Tracks the pending commit to prevent use-after-free conditions.
699 	 *
700 	 * Is only set when @crtc is NULL.
701 	 */
702 	struct drm_crtc_commit *commit;
703 
704 	/** @tv: TV connector state */
705 	struct drm_tv_connector_state tv;
706 
707 	/**
708 	 * @self_refresh_aware:
709 	 *
710 	 * This tracks whether a connector is aware of the self refresh state.
711 	 * It should be set to true for those connector implementations which
712 	 * understand the self refresh state. This is needed since the crtc
713 	 * registers the self refresh helpers and it doesn't know if the
714 	 * connectors downstream have implemented self refresh entry/exit.
715 	 *
716 	 * Drivers should set this to true in atomic_check if they know how to
717 	 * handle self_refresh requests.
718 	 */
719 	bool self_refresh_aware;
720 
721 	/**
722 	 * @picture_aspect_ratio: Connector property to control the
723 	 * HDMI infoframe aspect ratio setting.
724 	 *
725 	 * The %DRM_MODE_PICTURE_ASPECT_\* values much match the
726 	 * values for &enum hdmi_picture_aspect
727 	 */
728 	enum hdmi_picture_aspect picture_aspect_ratio;
729 
730 	/**
731 	 * @content_type: Connector property to control the
732 	 * HDMI infoframe content type setting.
733 	 * The %DRM_MODE_CONTENT_TYPE_\* values much
734 	 * match the values.
735 	 */
736 	unsigned int content_type;
737 
738 	/**
739 	 * @hdcp_content_type: Connector property to pass the type of
740 	 * protected content. This is most commonly used for HDCP.
741 	 */
742 	unsigned int hdcp_content_type;
743 
744 	/**
745 	 * @scaling_mode: Connector property to control the
746 	 * upscaling, mostly used for built-in panels.
747 	 */
748 	unsigned int scaling_mode;
749 
750 	/**
751 	 * @content_protection: Connector property to request content
752 	 * protection. This is most commonly used for HDCP.
753 	 */
754 	unsigned int content_protection;
755 
756 	/**
757 	 * @colorspace: State variable for Connector property to request
758 	 * colorspace change on Sink. This is most commonly used to switch
759 	 * to wider color gamuts like BT2020.
760 	 */
761 	u32 colorspace;
762 
763 	/**
764 	 * @writeback_job: Writeback job for writeback connectors
765 	 *
766 	 * Holds the framebuffer and out-fence for a writeback connector. As
767 	 * the writeback completion may be asynchronous to the normal commit
768 	 * cycle, the writeback job lifetime is managed separately from the
769 	 * normal atomic state by this object.
770 	 *
771 	 * See also: drm_writeback_queue_job() and
772 	 * drm_writeback_signal_completion()
773 	 */
774 	struct drm_writeback_job *writeback_job;
775 
776 	/**
777 	 * @max_requested_bpc: Connector property to limit the maximum bit
778 	 * depth of the pixels.
779 	 */
780 	u8 max_requested_bpc;
781 
782 	/**
783 	 * @max_bpc: Connector max_bpc based on the requested max_bpc property
784 	 * and the connector bpc limitations obtained from edid.
785 	 */
786 	u8 max_bpc;
787 
788 	/**
789 	 * @hdr_output_metadata:
790 	 * DRM blob property for HDR output metadata
791 	 */
792 	struct drm_property_blob *hdr_output_metadata;
793 };
794 
795 /**
796  * struct drm_connector_funcs - control connectors on a given device
797  *
798  * Each CRTC may have one or more connectors attached to it.  The functions
799  * below allow the core DRM code to control connectors, enumerate available modes,
800  * etc.
801  */
802 struct drm_connector_funcs {
803 	/**
804 	 * @dpms:
805 	 *
806 	 * Legacy entry point to set the per-connector DPMS state. Legacy DPMS
807 	 * is exposed as a standard property on the connector, but diverted to
808 	 * this callback in the drm core. Note that atomic drivers don't
809 	 * implement the 4 level DPMS support on the connector any more, but
810 	 * instead only have an on/off "ACTIVE" property on the CRTC object.
811 	 *
812 	 * This hook is not used by atomic drivers, remapping of the legacy DPMS
813 	 * property is entirely handled in the DRM core.
814 	 *
815 	 * RETURNS:
816 	 *
817 	 * 0 on success or a negative error code on failure.
818 	 */
819 	int (*dpms)(struct drm_connector *connector, int mode);
820 
821 	/**
822 	 * @reset:
823 	 *
824 	 * Reset connector hardware and software state to off. This function isn't
825 	 * called by the core directly, only through drm_mode_config_reset().
826 	 * It's not a helper hook only for historical reasons.
827 	 *
828 	 * Atomic drivers can use drm_atomic_helper_connector_reset() to reset
829 	 * atomic state using this hook.
830 	 */
831 	void (*reset)(struct drm_connector *connector);
832 
833 	/**
834 	 * @detect:
835 	 *
836 	 * Check to see if anything is attached to the connector. The parameter
837 	 * force is set to false whilst polling, true when checking the
838 	 * connector due to a user request. force can be used by the driver to
839 	 * avoid expensive, destructive operations during automated probing.
840 	 *
841 	 * This callback is optional, if not implemented the connector will be
842 	 * considered as always being attached.
843 	 *
844 	 * FIXME:
845 	 *
846 	 * Note that this hook is only called by the probe helper. It's not in
847 	 * the helper library vtable purely for historical reasons. The only DRM
848 	 * core	entry point to probe connector state is @fill_modes.
849 	 *
850 	 * Note that the helper library will already hold
851 	 * &drm_mode_config.connection_mutex. Drivers which need to grab additional
852 	 * locks to avoid races with concurrent modeset changes need to use
853 	 * &drm_connector_helper_funcs.detect_ctx instead.
854 	 *
855 	 * RETURNS:
856 	 *
857 	 * drm_connector_status indicating the connector's status.
858 	 */
859 	enum drm_connector_status (*detect)(struct drm_connector *connector,
860 					    bool force);
861 
862 	/**
863 	 * @force:
864 	 *
865 	 * This function is called to update internal encoder state when the
866 	 * connector is forced to a certain state by userspace, either through
867 	 * the sysfs interfaces or on the kernel cmdline. In that case the
868 	 * @detect callback isn't called.
869 	 *
870 	 * FIXME:
871 	 *
872 	 * Note that this hook is only called by the probe helper. It's not in
873 	 * the helper library vtable purely for historical reasons. The only DRM
874 	 * core	entry point to probe connector state is @fill_modes.
875 	 */
876 	void (*force)(struct drm_connector *connector);
877 
878 	/**
879 	 * @fill_modes:
880 	 *
881 	 * Entry point for output detection and basic mode validation. The
882 	 * driver should reprobe the output if needed (e.g. when hotplug
883 	 * handling is unreliable), add all detected modes to &drm_connector.modes
884 	 * and filter out any the device can't support in any configuration. It
885 	 * also needs to filter out any modes wider or higher than the
886 	 * parameters max_width and max_height indicate.
887 	 *
888 	 * The drivers must also prune any modes no longer valid from
889 	 * &drm_connector.modes. Furthermore it must update
890 	 * &drm_connector.status and &drm_connector.edid.  If no EDID has been
891 	 * received for this output connector->edid must be NULL.
892 	 *
893 	 * Drivers using the probe helpers should use
894 	 * drm_helper_probe_single_connector_modes() to implement this
895 	 * function.
896 	 *
897 	 * RETURNS:
898 	 *
899 	 * The number of modes detected and filled into &drm_connector.modes.
900 	 */
901 	int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height);
902 
903 	/**
904 	 * @set_property:
905 	 *
906 	 * This is the legacy entry point to update a property attached to the
907 	 * connector.
908 	 *
909 	 * This callback is optional if the driver does not support any legacy
910 	 * driver-private properties. For atomic drivers it is not used because
911 	 * property handling is done entirely in the DRM core.
912 	 *
913 	 * RETURNS:
914 	 *
915 	 * 0 on success or a negative error code on failure.
916 	 */
917 	int (*set_property)(struct drm_connector *connector, struct drm_property *property,
918 			     uint64_t val);
919 
920 	/**
921 	 * @late_register:
922 	 *
923 	 * This optional hook can be used to register additional userspace
924 	 * interfaces attached to the connector, light backlight control, i2c,
925 	 * DP aux or similar interfaces. It is called late in the driver load
926 	 * sequence from drm_connector_register() when registering all the
927 	 * core drm connector interfaces. Everything added from this callback
928 	 * should be unregistered in the early_unregister callback.
929 	 *
930 	 * This is called while holding &drm_connector.mutex.
931 	 *
932 	 * Returns:
933 	 *
934 	 * 0 on success, or a negative error code on failure.
935 	 */
936 	int (*late_register)(struct drm_connector *connector);
937 
938 	/**
939 	 * @early_unregister:
940 	 *
941 	 * This optional hook should be used to unregister the additional
942 	 * userspace interfaces attached to the connector from
943 	 * late_register(). It is called from drm_connector_unregister(),
944 	 * early in the driver unload sequence to disable userspace access
945 	 * before data structures are torndown.
946 	 *
947 	 * This is called while holding &drm_connector.mutex.
948 	 */
949 	void (*early_unregister)(struct drm_connector *connector);
950 
951 	/**
952 	 * @destroy:
953 	 *
954 	 * Clean up connector resources. This is called at driver unload time
955 	 * through drm_mode_config_cleanup(). It can also be called at runtime
956 	 * when a connector is being hot-unplugged for drivers that support
957 	 * connector hotplugging (e.g. DisplayPort MST).
958 	 */
959 	void (*destroy)(struct drm_connector *connector);
960 
961 	/**
962 	 * @atomic_duplicate_state:
963 	 *
964 	 * Duplicate the current atomic state for this connector and return it.
965 	 * The core and helpers guarantee that any atomic state duplicated with
966 	 * this hook and still owned by the caller (i.e. not transferred to the
967 	 * driver by calling &drm_mode_config_funcs.atomic_commit) will be
968 	 * cleaned up by calling the @atomic_destroy_state hook in this
969 	 * structure.
970 	 *
971 	 * This callback is mandatory for atomic drivers.
972 	 *
973 	 * Atomic drivers which don't subclass &struct drm_connector_state should use
974 	 * drm_atomic_helper_connector_duplicate_state(). Drivers that subclass the
975 	 * state structure to extend it with driver-private state should use
976 	 * __drm_atomic_helper_connector_duplicate_state() to make sure shared state is
977 	 * duplicated in a consistent fashion across drivers.
978 	 *
979 	 * It is an error to call this hook before &drm_connector.state has been
980 	 * initialized correctly.
981 	 *
982 	 * NOTE:
983 	 *
984 	 * If the duplicate state references refcounted resources this hook must
985 	 * acquire a reference for each of them. The driver must release these
986 	 * references again in @atomic_destroy_state.
987 	 *
988 	 * RETURNS:
989 	 *
990 	 * Duplicated atomic state or NULL when the allocation failed.
991 	 */
992 	struct drm_connector_state *(*atomic_duplicate_state)(struct drm_connector *connector);
993 
994 	/**
995 	 * @atomic_destroy_state:
996 	 *
997 	 * Destroy a state duplicated with @atomic_duplicate_state and release
998 	 * or unreference all resources it references
999 	 *
1000 	 * This callback is mandatory for atomic drivers.
1001 	 */
1002 	void (*atomic_destroy_state)(struct drm_connector *connector,
1003 				     struct drm_connector_state *state);
1004 
1005 	/**
1006 	 * @atomic_set_property:
1007 	 *
1008 	 * Decode a driver-private property value and store the decoded value
1009 	 * into the passed-in state structure. Since the atomic core decodes all
1010 	 * standardized properties (even for extensions beyond the core set of
1011 	 * properties which might not be implemented by all drivers) this
1012 	 * requires drivers to subclass the state structure.
1013 	 *
1014 	 * Such driver-private properties should really only be implemented for
1015 	 * truly hardware/vendor specific state. Instead it is preferred to
1016 	 * standardize atomic extension and decode the properties used to expose
1017 	 * such an extension in the core.
1018 	 *
1019 	 * Do not call this function directly, use
1020 	 * drm_atomic_connector_set_property() instead.
1021 	 *
1022 	 * This callback is optional if the driver does not support any
1023 	 * driver-private atomic properties.
1024 	 *
1025 	 * NOTE:
1026 	 *
1027 	 * This function is called in the state assembly phase of atomic
1028 	 * modesets, which can be aborted for any reason (including on
1029 	 * userspace's request to just check whether a configuration would be
1030 	 * possible). Drivers MUST NOT touch any persistent state (hardware or
1031 	 * software) or data structures except the passed in @state parameter.
1032 	 *
1033 	 * Also since userspace controls in which order properties are set this
1034 	 * function must not do any input validation (since the state update is
1035 	 * incomplete and hence likely inconsistent). Instead any such input
1036 	 * validation must be done in the various atomic_check callbacks.
1037 	 *
1038 	 * RETURNS:
1039 	 *
1040 	 * 0 if the property has been found, -EINVAL if the property isn't
1041 	 * implemented by the driver (which shouldn't ever happen, the core only
1042 	 * asks for properties attached to this connector). No other validation
1043 	 * is allowed by the driver. The core already checks that the property
1044 	 * value is within the range (integer, valid enum value, ...) the driver
1045 	 * set when registering the property.
1046 	 */
1047 	int (*atomic_set_property)(struct drm_connector *connector,
1048 				   struct drm_connector_state *state,
1049 				   struct drm_property *property,
1050 				   uint64_t val);
1051 
1052 	/**
1053 	 * @atomic_get_property:
1054 	 *
1055 	 * Reads out the decoded driver-private property. This is used to
1056 	 * implement the GETCONNECTOR IOCTL.
1057 	 *
1058 	 * Do not call this function directly, use
1059 	 * drm_atomic_connector_get_property() instead.
1060 	 *
1061 	 * This callback is optional if the driver does not support any
1062 	 * driver-private atomic properties.
1063 	 *
1064 	 * RETURNS:
1065 	 *
1066 	 * 0 on success, -EINVAL if the property isn't implemented by the
1067 	 * driver (which shouldn't ever happen, the core only asks for
1068 	 * properties attached to this connector).
1069 	 */
1070 	int (*atomic_get_property)(struct drm_connector *connector,
1071 				   const struct drm_connector_state *state,
1072 				   struct drm_property *property,
1073 				   uint64_t *val);
1074 
1075 	/**
1076 	 * @atomic_print_state:
1077 	 *
1078 	 * If driver subclasses &struct drm_connector_state, it should implement
1079 	 * this optional hook for printing additional driver specific state.
1080 	 *
1081 	 * Do not call this directly, use drm_atomic_connector_print_state()
1082 	 * instead.
1083 	 */
1084 	void (*atomic_print_state)(struct drm_printer *p,
1085 				   const struct drm_connector_state *state);
1086 };
1087 
1088 /**
1089  * struct drm_cmdline_mode - DRM Mode passed through the kernel command-line
1090  *
1091  * Each connector can have an initial mode with additional options
1092  * passed through the kernel command line. This structure allows to
1093  * express those parameters and will be filled by the command-line
1094  * parser.
1095  */
1096 struct drm_cmdline_mode {
1097 	/**
1098 	 * @name:
1099 	 *
1100 	 * Name of the mode.
1101 	 */
1102 	char name[DRM_DISPLAY_MODE_LEN];
1103 
1104 	/**
1105 	 * @specified:
1106 	 *
1107 	 * Has a mode been read from the command-line?
1108 	 */
1109 	bool specified;
1110 
1111 	/**
1112 	 * @refresh_specified:
1113 	 *
1114 	 * Did the mode have a preferred refresh rate?
1115 	 */
1116 	bool refresh_specified;
1117 
1118 	/**
1119 	 * @bpp_specified:
1120 	 *
1121 	 * Did the mode have a preferred BPP?
1122 	 */
1123 	bool bpp_specified;
1124 
1125 	/**
1126 	 * @xres:
1127 	 *
1128 	 * Active resolution on the X axis, in pixels.
1129 	 */
1130 	int xres;
1131 
1132 	/**
1133 	 * @yres:
1134 	 *
1135 	 * Active resolution on the Y axis, in pixels.
1136 	 */
1137 	int yres;
1138 
1139 	/**
1140 	 * @bpp:
1141 	 *
1142 	 * Bits per pixels for the mode.
1143 	 */
1144 	int bpp;
1145 
1146 	/**
1147 	 * @refresh:
1148 	 *
1149 	 * Refresh rate, in Hertz.
1150 	 */
1151 	int refresh;
1152 
1153 	/**
1154 	 * @rb:
1155 	 *
1156 	 * Do we need to use reduced blanking?
1157 	 */
1158 	bool rb;
1159 
1160 	/**
1161 	 * @interlace:
1162 	 *
1163 	 * The mode is interlaced.
1164 	 */
1165 	bool interlace;
1166 
1167 	/**
1168 	 * @cvt:
1169 	 *
1170 	 * The timings will be calculated using the VESA Coordinated
1171 	 * Video Timings instead of looking up the mode from a table.
1172 	 */
1173 	bool cvt;
1174 
1175 	/**
1176 	 * @margins:
1177 	 *
1178 	 * Add margins to the mode calculation (1.8% of xres rounded
1179 	 * down to 8 pixels and 1.8% of yres).
1180 	 */
1181 	bool margins;
1182 
1183 	/**
1184 	 * @force:
1185 	 *
1186 	 * Ignore the hotplug state of the connector, and force its
1187 	 * state to one of the DRM_FORCE_* values.
1188 	 */
1189 	enum drm_connector_force force;
1190 
1191 	/**
1192 	 * @rotation_reflection:
1193 	 *
1194 	 * Initial rotation and reflection of the mode setup from the
1195 	 * command line. See DRM_MODE_ROTATE_* and
1196 	 * DRM_MODE_REFLECT_*. The only rotations supported are
1197 	 * DRM_MODE_ROTATE_0 and DRM_MODE_ROTATE_180.
1198 	 */
1199 	unsigned int rotation_reflection;
1200 
1201 	/**
1202 	 * @panel_orientation:
1203 	 *
1204 	 * drm-connector "panel orientation" property override value,
1205 	 * DRM_MODE_PANEL_ORIENTATION_UNKNOWN if not set.
1206 	 */
1207 	enum drm_panel_orientation panel_orientation;
1208 
1209 	/**
1210 	 * @tv_margins: TV margins to apply to the mode.
1211 	 */
1212 	struct drm_connector_tv_margins tv_margins;
1213 };
1214 
1215 /**
1216  * struct drm_connector - central DRM connector control structure
1217  *
1218  * Each connector may be connected to one or more CRTCs, or may be clonable by
1219  * another connector if they can share a CRTC.  Each connector also has a specific
1220  * position in the broader display (referred to as a 'screen' though it could
1221  * span multiple monitors).
1222  */
1223 struct drm_connector {
1224 	/** @dev: parent DRM device */
1225 	struct drm_device *dev;
1226 	/** @kdev: kernel device for sysfs attributes */
1227 	struct device *kdev;
1228 	/** @attr: sysfs attributes */
1229 	struct device_attribute *attr;
1230 
1231 	/**
1232 	 * @head:
1233 	 *
1234 	 * List of all connectors on a @dev, linked from
1235 	 * &drm_mode_config.connector_list. Protected by
1236 	 * &drm_mode_config.connector_list_lock, but please only use
1237 	 * &drm_connector_list_iter to walk this list.
1238 	 */
1239 	struct list_head head;
1240 
1241 	/** @base: base KMS object */
1242 	struct drm_mode_object base;
1243 
1244 	/** @name: human readable name, can be overwritten by the driver */
1245 	char *name;
1246 
1247 	/**
1248 	 * @mutex: Lock for general connector state, but currently only protects
1249 	 * @registered. Most of the connector state is still protected by
1250 	 * &drm_mode_config.mutex.
1251 	 */
1252 	struct mutex mutex;
1253 
1254 	/**
1255 	 * @index: Compacted connector index, which matches the position inside
1256 	 * the mode_config.list for drivers not supporting hot-add/removing. Can
1257 	 * be used as an array index. It is invariant over the lifetime of the
1258 	 * connector.
1259 	 */
1260 	unsigned index;
1261 
1262 	/**
1263 	 * @connector_type:
1264 	 * one of the DRM_MODE_CONNECTOR_<foo> types from drm_mode.h
1265 	 */
1266 	int connector_type;
1267 	/** @connector_type_id: index into connector type enum */
1268 	int connector_type_id;
1269 	/**
1270 	 * @interlace_allowed:
1271 	 * Can this connector handle interlaced modes? Only used by
1272 	 * drm_helper_probe_single_connector_modes() for mode filtering.
1273 	 */
1274 	bool interlace_allowed;
1275 	/**
1276 	 * @doublescan_allowed:
1277 	 * Can this connector handle doublescan? Only used by
1278 	 * drm_helper_probe_single_connector_modes() for mode filtering.
1279 	 */
1280 	bool doublescan_allowed;
1281 	/**
1282 	 * @stereo_allowed:
1283 	 * Can this connector handle stereo modes? Only used by
1284 	 * drm_helper_probe_single_connector_modes() for mode filtering.
1285 	 */
1286 	bool stereo_allowed;
1287 
1288 	/**
1289 	 * @ycbcr_420_allowed : This bool indicates if this connector is
1290 	 * capable of handling YCBCR 420 output. While parsing the EDID
1291 	 * blocks it's very helpful to know if the source is capable of
1292 	 * handling YCBCR 420 outputs.
1293 	 */
1294 	bool ycbcr_420_allowed;
1295 
1296 	/**
1297 	 * @registration_state: Is this connector initializing, exposed
1298 	 * (registered) with userspace, or unregistered?
1299 	 *
1300 	 * Protected by @mutex.
1301 	 */
1302 	enum drm_connector_registration_state registration_state;
1303 
1304 	/**
1305 	 * @modes:
1306 	 * Modes available on this connector (from fill_modes() + user).
1307 	 * Protected by &drm_mode_config.mutex.
1308 	 */
1309 	struct list_head modes;
1310 
1311 	/**
1312 	 * @status:
1313 	 * One of the drm_connector_status enums (connected, not, or unknown).
1314 	 * Protected by &drm_mode_config.mutex.
1315 	 */
1316 	enum drm_connector_status status;
1317 
1318 	/**
1319 	 * @probed_modes:
1320 	 * These are modes added by probing with DDC or the BIOS, before
1321 	 * filtering is applied. Used by the probe helpers. Protected by
1322 	 * &drm_mode_config.mutex.
1323 	 */
1324 	struct list_head probed_modes;
1325 
1326 	/**
1327 	 * @display_info: Display information is filled from EDID information
1328 	 * when a display is detected. For non hot-pluggable displays such as
1329 	 * flat panels in embedded systems, the driver should initialize the
1330 	 * &drm_display_info.width_mm and &drm_display_info.height_mm fields
1331 	 * with the physical size of the display.
1332 	 *
1333 	 * Protected by &drm_mode_config.mutex.
1334 	 */
1335 	struct drm_display_info display_info;
1336 
1337 	/** @funcs: connector control functions */
1338 	const struct drm_connector_funcs *funcs;
1339 
1340 	/**
1341 	 * @edid_blob_ptr: DRM property containing EDID if present. Protected by
1342 	 * &drm_mode_config.mutex. This should be updated only by calling
1343 	 * drm_connector_update_edid_property().
1344 	 */
1345 	struct drm_property_blob *edid_blob_ptr;
1346 
1347 	/** @properties: property tracking for this connector */
1348 	struct drm_object_properties properties;
1349 
1350 	/**
1351 	 * @scaling_mode_property: Optional atomic property to control the
1352 	 * upscaling. See drm_connector_attach_content_protection_property().
1353 	 */
1354 	struct drm_property *scaling_mode_property;
1355 
1356 	/**
1357 	 * @vrr_capable_property: Optional property to help userspace
1358 	 * query hardware support for variable refresh rate on a connector.
1359 	 * connector. Drivers can add the property to a connector by
1360 	 * calling drm_connector_attach_vrr_capable_property().
1361 	 *
1362 	 * This should be updated only by calling
1363 	 * drm_connector_set_vrr_capable_property().
1364 	 */
1365 	struct drm_property *vrr_capable_property;
1366 
1367 	/**
1368 	 * @colorspace_property: Connector property to set the suitable
1369 	 * colorspace supported by the sink.
1370 	 */
1371 	struct drm_property *colorspace_property;
1372 
1373 	/**
1374 	 * @path_blob_ptr:
1375 	 *
1376 	 * DRM blob property data for the DP MST path property. This should only
1377 	 * be updated by calling drm_connector_set_path_property().
1378 	 */
1379 	struct drm_property_blob *path_blob_ptr;
1380 
1381 	/**
1382 	 * @max_bpc_property: Default connector property for the max bpc to be
1383 	 * driven out of the connector.
1384 	 */
1385 	struct drm_property *max_bpc_property;
1386 
1387 #define DRM_CONNECTOR_POLL_HPD (1 << 0)
1388 #define DRM_CONNECTOR_POLL_CONNECT (1 << 1)
1389 #define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2)
1390 
1391 	/**
1392 	 * @polled:
1393 	 *
1394 	 * Connector polling mode, a combination of
1395 	 *
1396 	 * DRM_CONNECTOR_POLL_HPD
1397 	 *     The connector generates hotplug events and doesn't need to be
1398 	 *     periodically polled. The CONNECT and DISCONNECT flags must not
1399 	 *     be set together with the HPD flag.
1400 	 *
1401 	 * DRM_CONNECTOR_POLL_CONNECT
1402 	 *     Periodically poll the connector for connection.
1403 	 *
1404 	 * DRM_CONNECTOR_POLL_DISCONNECT
1405 	 *     Periodically poll the connector for disconnection, without
1406 	 *     causing flickering even when the connector is in use. DACs should
1407 	 *     rarely do this without a lot of testing.
1408 	 *
1409 	 * Set to 0 for connectors that don't support connection status
1410 	 * discovery.
1411 	 */
1412 	uint8_t polled;
1413 
1414 	/**
1415 	 * @dpms: Current dpms state. For legacy drivers the
1416 	 * &drm_connector_funcs.dpms callback must update this. For atomic
1417 	 * drivers, this is handled by the core atomic code, and drivers must
1418 	 * only take &drm_crtc_state.active into account.
1419 	 */
1420 	int dpms;
1421 
1422 	/** @helper_private: mid-layer private data */
1423 	const struct drm_connector_helper_funcs *helper_private;
1424 
1425 	/** @cmdline_mode: mode line parsed from the kernel cmdline for this connector */
1426 	struct drm_cmdline_mode cmdline_mode;
1427 	/** @force: a DRM_FORCE_<foo> state for forced mode sets */
1428 	enum drm_connector_force force;
1429 	/** @override_edid: has the EDID been overwritten through debugfs for testing? */
1430 	bool override_edid;
1431 	/** @epoch_counter: used to detect any other changes in connector, besides status */
1432 	u64 epoch_counter;
1433 
1434 	/**
1435 	 * @possible_encoders: Bit mask of encoders that can drive this
1436 	 * connector, drm_encoder_index() determines the index into the bitfield
1437 	 * and the bits are set with drm_connector_attach_encoder().
1438 	 */
1439 	u32 possible_encoders;
1440 
1441 	/**
1442 	 * @encoder: Currently bound encoder driving this connector, if any.
1443 	 * Only really meaningful for non-atomic drivers. Atomic drivers should
1444 	 * instead look at &drm_connector_state.best_encoder, and in case they
1445 	 * need the CRTC driving this output, &drm_connector_state.crtc.
1446 	 */
1447 	struct drm_encoder *encoder;
1448 
1449 #define MAX_ELD_BYTES	128
1450 	/** @eld: EDID-like data, if present */
1451 	uint8_t eld[MAX_ELD_BYTES];
1452 	/** @latency_present: AV delay info from ELD, if found */
1453 	bool latency_present[2];
1454 	/**
1455 	 * @video_latency: Video latency info from ELD, if found.
1456 	 * [0]: progressive, [1]: interlaced
1457 	 */
1458 	int video_latency[2];
1459 	/**
1460 	 * @audio_latency: audio latency info from ELD, if found
1461 	 * [0]: progressive, [1]: interlaced
1462 	 */
1463 	int audio_latency[2];
1464 
1465 	/**
1466 	 * @ddc: associated ddc adapter.
1467 	 * A connector usually has its associated ddc adapter. If a driver uses
1468 	 * this field, then an appropriate symbolic link is created in connector
1469 	 * sysfs directory to make it easy for the user to tell which i2c
1470 	 * adapter is for a particular display.
1471 	 *
1472 	 * The field should be set by calling drm_connector_init_with_ddc().
1473 	 */
1474 	struct i2c_adapter *ddc;
1475 
1476 	/**
1477 	 * @null_edid_counter: track sinks that give us all zeros for the EDID.
1478 	 * Needed to workaround some HW bugs where we get all 0s
1479 	 */
1480 	int null_edid_counter;
1481 
1482 	/** @bad_edid_counter: track sinks that give us an EDID with invalid checksum */
1483 	unsigned bad_edid_counter;
1484 
1485 	/**
1486 	 * @edid_corrupt: Indicates whether the last read EDID was corrupt. Used
1487 	 * in Displayport compliance testing - Displayport Link CTS Core 1.2
1488 	 * rev1.1 4.2.2.6
1489 	 */
1490 	bool edid_corrupt;
1491 	/**
1492 	 * @real_edid_checksum: real edid checksum for corrupted edid block.
1493 	 * Required in Displayport 1.4 compliance testing
1494 	 * rev1.1 4.2.2.6
1495 	 */
1496 	u8 real_edid_checksum;
1497 
1498 	/** @debugfs_entry: debugfs directory for this connector */
1499 	struct dentry *debugfs_entry;
1500 
1501 	/**
1502 	 * @state:
1503 	 *
1504 	 * Current atomic state for this connector.
1505 	 *
1506 	 * This is protected by &drm_mode_config.connection_mutex. Note that
1507 	 * nonblocking atomic commits access the current connector state without
1508 	 * taking locks. Either by going through the &struct drm_atomic_state
1509 	 * pointers, see for_each_oldnew_connector_in_state(),
1510 	 * for_each_old_connector_in_state() and
1511 	 * for_each_new_connector_in_state(). Or through careful ordering of
1512 	 * atomic commit operations as implemented in the atomic helpers, see
1513 	 * &struct drm_crtc_commit.
1514 	 */
1515 	struct drm_connector_state *state;
1516 
1517 	/* DisplayID bits. FIXME: Extract into a substruct? */
1518 
1519 	/**
1520 	 * @tile_blob_ptr:
1521 	 *
1522 	 * DRM blob property data for the tile property (used mostly by DP MST).
1523 	 * This is meant for screens which are driven through separate display
1524 	 * pipelines represented by &drm_crtc, which might not be running with
1525 	 * genlocked clocks. For tiled panels which are genlocked, like
1526 	 * dual-link LVDS or dual-link DSI, the driver should try to not expose
1527 	 * the tiling and virtualize both &drm_crtc and &drm_plane if needed.
1528 	 *
1529 	 * This should only be updated by calling
1530 	 * drm_connector_set_tile_property().
1531 	 */
1532 	struct drm_property_blob *tile_blob_ptr;
1533 
1534 	/** @has_tile: is this connector connected to a tiled monitor */
1535 	bool has_tile;
1536 	/** @tile_group: tile group for the connected monitor */
1537 	struct drm_tile_group *tile_group;
1538 	/** @tile_is_single_monitor: whether the tile is one monitor housing */
1539 	bool tile_is_single_monitor;
1540 
1541 	/** @num_h_tile: number of horizontal tiles in the tile group */
1542 	/** @num_v_tile: number of vertical tiles in the tile group */
1543 	uint8_t num_h_tile, num_v_tile;
1544 	/** @tile_h_loc: horizontal location of this tile */
1545 	/** @tile_v_loc: vertical location of this tile */
1546 	uint8_t tile_h_loc, tile_v_loc;
1547 	/** @tile_h_size: horizontal size of this tile. */
1548 	/** @tile_v_size: vertical size of this tile. */
1549 	uint16_t tile_h_size, tile_v_size;
1550 
1551 	/**
1552 	 * @free_node:
1553 	 *
1554 	 * List used only by &drm_connector_list_iter to be able to clean up a
1555 	 * connector from any context, in conjunction with
1556 	 * &drm_mode_config.connector_free_work.
1557 	 */
1558 	struct llist_node free_node;
1559 
1560 	/** @hdr_sink_metadata: HDR Metadata Information read from sink */
1561 	struct hdr_sink_metadata hdr_sink_metadata;
1562 };
1563 
1564 #define obj_to_connector(x) container_of(x, struct drm_connector, base)
1565 
1566 int drm_connector_init(struct drm_device *dev,
1567 		       struct drm_connector *connector,
1568 		       const struct drm_connector_funcs *funcs,
1569 		       int connector_type);
1570 int drm_connector_init_with_ddc(struct drm_device *dev,
1571 				struct drm_connector *connector,
1572 				const struct drm_connector_funcs *funcs,
1573 				int connector_type,
1574 				struct i2c_adapter *ddc);
1575 void drm_connector_attach_edid_property(struct drm_connector *connector);
1576 int drm_connector_register(struct drm_connector *connector);
1577 void drm_connector_unregister(struct drm_connector *connector);
1578 int drm_connector_attach_encoder(struct drm_connector *connector,
1579 				      struct drm_encoder *encoder);
1580 
1581 void drm_connector_cleanup(struct drm_connector *connector);
1582 
drm_connector_index(const struct drm_connector * connector)1583 static inline unsigned int drm_connector_index(const struct drm_connector *connector)
1584 {
1585 	return connector->index;
1586 }
1587 
drm_connector_mask(const struct drm_connector * connector)1588 static inline u32 drm_connector_mask(const struct drm_connector *connector)
1589 {
1590 	return 1 << connector->index;
1591 }
1592 
1593 /**
1594  * drm_connector_lookup - lookup connector object
1595  * @dev: DRM device
1596  * @file_priv: drm file to check for lease against.
1597  * @id: connector object id
1598  *
1599  * This function looks up the connector object specified by id
1600  * add takes a reference to it.
1601  */
drm_connector_lookup(struct drm_device * dev,struct drm_file * file_priv,uint32_t id)1602 static inline struct drm_connector *drm_connector_lookup(struct drm_device *dev,
1603 		struct drm_file *file_priv,
1604 		uint32_t id)
1605 {
1606 	struct drm_mode_object *mo;
1607 	mo = drm_mode_object_find(dev, file_priv, id, DRM_MODE_OBJECT_CONNECTOR);
1608 	return mo ? obj_to_connector(mo) : NULL;
1609 }
1610 
1611 /**
1612  * drm_connector_get - acquire a connector reference
1613  * @connector: DRM connector
1614  *
1615  * This function increments the connector's refcount.
1616  */
drm_connector_get(struct drm_connector * connector)1617 static inline void drm_connector_get(struct drm_connector *connector)
1618 {
1619 	drm_mode_object_get(&connector->base);
1620 }
1621 
1622 /**
1623  * drm_connector_put - release a connector reference
1624  * @connector: DRM connector
1625  *
1626  * This function decrements the connector's reference count and frees the
1627  * object if the reference count drops to zero.
1628  */
drm_connector_put(struct drm_connector * connector)1629 static inline void drm_connector_put(struct drm_connector *connector)
1630 {
1631 	drm_mode_object_put(&connector->base);
1632 }
1633 
1634 /**
1635  * drm_connector_is_unregistered - has the connector been unregistered from
1636  * userspace?
1637  * @connector: DRM connector
1638  *
1639  * Checks whether or not @connector has been unregistered from userspace.
1640  *
1641  * Returns:
1642  * True if the connector was unregistered, false if the connector is
1643  * registered or has not yet been registered with userspace.
1644  */
1645 static inline bool
drm_connector_is_unregistered(struct drm_connector * connector)1646 drm_connector_is_unregistered(struct drm_connector *connector)
1647 {
1648 	return READ_ONCE(connector->registration_state) ==
1649 		DRM_CONNECTOR_UNREGISTERED;
1650 }
1651 
1652 void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode);
1653 const char *drm_get_connector_type_name(unsigned int connector_type);
1654 const char *drm_get_connector_status_name(enum drm_connector_status status);
1655 const char *drm_get_subpixel_order_name(enum subpixel_order order);
1656 const char *drm_get_dpms_name(int val);
1657 const char *drm_get_dvi_i_subconnector_name(int val);
1658 const char *drm_get_dvi_i_select_name(int val);
1659 const char *drm_get_tv_subconnector_name(int val);
1660 const char *drm_get_tv_select_name(int val);
1661 const char *drm_get_dp_subconnector_name(int val);
1662 const char *drm_get_content_protection_name(int val);
1663 const char *drm_get_hdcp_content_type_name(int val);
1664 
1665 int drm_mode_create_dvi_i_properties(struct drm_device *dev);
1666 void drm_connector_attach_dp_subconnector_property(struct drm_connector *connector);
1667 
1668 int drm_mode_create_tv_margin_properties(struct drm_device *dev);
1669 int drm_mode_create_tv_properties(struct drm_device *dev,
1670 				  unsigned int num_modes,
1671 				  const char * const modes[]);
1672 void drm_connector_attach_tv_margin_properties(struct drm_connector *conn);
1673 int drm_mode_create_scaling_mode_property(struct drm_device *dev);
1674 int drm_connector_attach_content_type_property(struct drm_connector *dev);
1675 int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,
1676 					       u32 scaling_mode_mask);
1677 int drm_connector_attach_vrr_capable_property(
1678 		struct drm_connector *connector);
1679 int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
1680 int drm_mode_create_hdmi_colorspace_property(struct drm_connector *connector);
1681 int drm_mode_create_dp_colorspace_property(struct drm_connector *connector);
1682 int drm_mode_create_content_type_property(struct drm_device *dev);
1683 void drm_hdmi_avi_infoframe_content_type(struct hdmi_avi_infoframe *frame,
1684 					 const struct drm_connector_state *conn_state);
1685 
1686 int drm_mode_create_suggested_offset_properties(struct drm_device *dev);
1687 
1688 int drm_connector_set_path_property(struct drm_connector *connector,
1689 				    const char *path);
1690 int drm_connector_set_tile_property(struct drm_connector *connector);
1691 int drm_connector_update_edid_property(struct drm_connector *connector,
1692 				       const struct edid *edid);
1693 void drm_connector_set_link_status_property(struct drm_connector *connector,
1694 					    uint64_t link_status);
1695 void drm_connector_set_vrr_capable_property(
1696 		struct drm_connector *connector, bool capable);
1697 int drm_connector_set_panel_orientation(
1698 	struct drm_connector *connector,
1699 	enum drm_panel_orientation panel_orientation);
1700 int drm_connector_set_panel_orientation_with_quirk(
1701 	struct drm_connector *connector,
1702 	enum drm_panel_orientation panel_orientation,
1703 	int width, int height);
1704 int drm_connector_attach_max_bpc_property(struct drm_connector *connector,
1705 					  int min, int max);
1706 
1707 /**
1708  * struct drm_tile_group - Tile group metadata
1709  * @refcount: reference count
1710  * @dev: DRM device
1711  * @id: tile group id exposed to userspace
1712  * @group_data: Sink-private data identifying this group
1713  *
1714  * @group_data corresponds to displayid vend/prod/serial for external screens
1715  * with an EDID.
1716  */
1717 struct drm_tile_group {
1718 	struct kref refcount;
1719 	struct drm_device *dev;
1720 	int id;
1721 	u8 group_data[8];
1722 };
1723 
1724 struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
1725 						  const char topology[8]);
1726 struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
1727 					       const char topology[8]);
1728 void drm_mode_put_tile_group(struct drm_device *dev,
1729 			     struct drm_tile_group *tg);
1730 
1731 /**
1732  * struct drm_connector_list_iter - connector_list iterator
1733  *
1734  * This iterator tracks state needed to be able to walk the connector_list
1735  * within struct drm_mode_config. Only use together with
1736  * drm_connector_list_iter_begin(), drm_connector_list_iter_end() and
1737  * drm_connector_list_iter_next() respectively the convenience macro
1738  * drm_for_each_connector_iter().
1739  */
1740 struct drm_connector_list_iter {
1741 /* private: */
1742 	struct drm_device *dev;
1743 	struct drm_connector *conn;
1744 };
1745 
1746 void drm_connector_list_iter_begin(struct drm_device *dev,
1747 				   struct drm_connector_list_iter *iter);
1748 struct drm_connector *
1749 drm_connector_list_iter_next(struct drm_connector_list_iter *iter);
1750 void drm_connector_list_iter_end(struct drm_connector_list_iter *iter);
1751 
1752 bool drm_connector_has_possible_encoder(struct drm_connector *connector,
1753 					struct drm_encoder *encoder);
1754 
1755 /**
1756  * drm_for_each_connector_iter - connector_list iterator macro
1757  * @connector: &struct drm_connector pointer used as cursor
1758  * @iter: &struct drm_connector_list_iter
1759  *
1760  * Note that @connector is only valid within the list body, if you want to use
1761  * @connector after calling drm_connector_list_iter_end() then you need to grab
1762  * your own reference first using drm_connector_get().
1763  */
1764 #define drm_for_each_connector_iter(connector, iter) \
1765 	while ((connector = drm_connector_list_iter_next(iter)))
1766 
1767 /**
1768  * drm_connector_for_each_possible_encoder - iterate connector's possible encoders
1769  * @connector: &struct drm_connector pointer
1770  * @encoder: &struct drm_encoder pointer used as cursor
1771  */
1772 #define drm_connector_for_each_possible_encoder(connector, encoder) \
1773 	drm_for_each_encoder_mask(encoder, (connector)->dev, \
1774 				  (connector)->possible_encoders)
1775 
1776 #endif
1777