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