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