]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/drm/drm_connector.h
drm/doc: remove standard connector props from the csv file
[mirror_ubuntu-bionic-kernel.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>
27#include <linux/ctype.h>
949619f3 28#include <drm/drm_mode_object.h>
52217195 29
199e4e96
DV
30#include <uapi/drm/drm_mode.h>
31
32struct drm_device;
33
52217195
DV
34struct drm_connector_helper_funcs;
35struct drm_device;
36struct drm_crtc;
37struct drm_encoder;
38struct drm_property;
39struct drm_property_blob;
fceffb32 40struct drm_printer;
52217195
DV
41struct edid;
42
43enum drm_connector_force {
44 DRM_FORCE_UNSPECIFIED,
45 DRM_FORCE_OFF,
46 DRM_FORCE_ON, /* force on analog part normally */
47 DRM_FORCE_ON_DIGITAL, /* for DVI-I use digital connector */
48};
49
ae2a6da8
DV
50/**
51 * enum drm_connector_status - status for a &drm_connector
52 *
53 * This enum is used to track the connector status. There are no separate
54 * #defines for the uapi!
55 */
52217195 56enum drm_connector_status {
ae2a6da8
DV
57 /**
58 * @connector_status_connected: The connector is definitely connected to
59 * a sink device, and can be enabled.
60 */
52217195 61 connector_status_connected = 1,
ae2a6da8
DV
62 /**
63 * @connector_status_disconnected: The connector isn't connected to a
64 * sink device which can be autodetect. For digital outputs like DP or
65 * HDMI (which can be realiable probed) this means there's really
66 * nothing there. It is driver-dependent whether a connector with this
67 * status can be lit up or not.
68 */
52217195 69 connector_status_disconnected = 2,
ae2a6da8
DV
70 /**
71 * @connector_status_unknown: The connector's status could not be
72 * reliably detected. This happens when probing would either cause
73 * flicker (like load-detection when the connector is in use), or when a
74 * hardware resource isn't available (like when load-detection needs a
75 * free CRTC). It should be possible to light up the connector with one
76 * of the listed fallback modes. For default configuration userspace
77 * should only try to light up connectors with unknown status when
78 * there's not connector with @connector_status_connected.
79 */
52217195
DV
80 connector_status_unknown = 3,
81};
82
83enum subpixel_order {
84 SubPixelUnknown = 0,
85 SubPixelHorizontalRGB,
86 SubPixelHorizontalBGR,
87 SubPixelVerticalRGB,
88 SubPixelVerticalBGR,
89 SubPixelNone,
afa1c763
SS
90
91};
92
62c58af3
SS
93/**
94 * struct drm_scrambling: sink's scrambling support.
95 */
96struct drm_scrambling {
97 /**
98 * @supported: scrambling supported for rates > 340 Mhz.
99 */
100 bool supported;
101 /**
102 * @low_rates: scrambling supported for rates <= 340 Mhz.
103 */
104 bool low_rates;
105};
106
afa1c763
SS
107/*
108 * struct drm_scdc - Information about scdc capabilities of a HDMI 2.0 sink
109 *
110 * Provides SCDC register support and capabilities related information on a
111 * HDMI 2.0 sink. In case of a HDMI 1.4 sink, all parameter must be 0.
112 */
113struct drm_scdc {
114 /**
115 * @supported: status control & data channel present.
116 */
117 bool supported;
118 /**
119 * @read_request: sink is capable of generating scdc read request.
120 */
121 bool read_request;
62c58af3
SS
122 /**
123 * @scrambling: sink's scrambling capabilities
124 */
125 struct drm_scrambling scrambling;
afa1c763
SS
126};
127
62c58af3 128
afa1c763
SS
129/**
130 * struct drm_hdmi_info - runtime information about the connected HDMI sink
131 *
132 * Describes if a given display supports advanced HDMI 2.0 features.
133 * This information is available in CEA-861-F extension blocks (like HF-VSDB).
134 */
135struct drm_hdmi_info {
86cc921c 136 /** @scdc: sink's scdc support and capabilities */
afa1c763 137 struct drm_scdc scdc;
52217195
DV
138};
139
40ee6fbe
MN
140/**
141 * enum drm_link_status - connector's link_status property value
142 *
143 * This enum is used as the connector's link status property value.
144 * It is set to the values defined in uapi.
41232c1b
MN
145 *
146 * @DRM_LINK_STATUS_GOOD: DP Link is Good as a result of successful
147 * link training
148 * @DRM_LINK_STATUS_BAD: DP Link is BAD as a result of link training
149 * failure
40ee6fbe
MN
150 */
151enum drm_link_status {
152 DRM_LINK_STATUS_GOOD = DRM_MODE_LINK_STATUS_GOOD,
153 DRM_LINK_STATUS_BAD = DRM_MODE_LINK_STATUS_BAD,
154};
155
b3c6c8bf
DV
156/**
157 * struct drm_display_info - runtime data about the connected sink
158 *
159 * Describes a given display (e.g. CRT or flat panel) and its limitations. For
160 * fixed display sinks like built-in panels there's not much difference between
ea0dd85a 161 * this and &struct drm_connector. But for sinks with a real cable this
b3c6c8bf
DV
162 * structure is meant to describe all the things at the other end of the cable.
163 *
164 * For sinks which provide an EDID this can be filled out by calling
165 * drm_add_edid_modes().
52217195
DV
166 */
167struct drm_display_info {
b3c6c8bf
DV
168 /**
169 * @name: Name of the display.
170 */
52217195
DV
171 char name[DRM_DISPLAY_INFO_LEN];
172
b3c6c8bf
DV
173 /**
174 * @width_mm: Physical width in mm.
175 */
52217195 176 unsigned int width_mm;
b3c6c8bf
DV
177 /**
178 * @height_mm: Physical height in mm.
179 */
52217195
DV
180 unsigned int height_mm;
181
b3c6c8bf
DV
182 /**
183 * @pixel_clock: Maximum pixel clock supported by the sink, in units of
188f7882 184 * 100Hz. This mismatches the clock in &drm_display_mode (which is in
b3c6c8bf
DV
185 * kHZ), because that's what the EDID uses as base unit.
186 */
52217195 187 unsigned int pixel_clock;
b3c6c8bf
DV
188 /**
189 * @bpc: Maximum bits per color channel. Used by HDMI and DP outputs.
190 */
52217195
DV
191 unsigned int bpc;
192
b3c6c8bf
DV
193 /**
194 * @subpixel_order: Subpixel order of LCD panels.
195 */
52217195
DV
196 enum subpixel_order subpixel_order;
197
198#define DRM_COLOR_FORMAT_RGB444 (1<<0)
199#define DRM_COLOR_FORMAT_YCRCB444 (1<<1)
200#define DRM_COLOR_FORMAT_YCRCB422 (1<<2)
201
b3c6c8bf
DV
202 /**
203 * @color_formats: HDMI Color formats, selects between RGB and YCrCb
204 * modes. Used DRM_COLOR_FORMAT\_ defines, which are _not_ the same ones
205 * as used to describe the pixel format in framebuffers, and also don't
206 * match the formats in @bus_formats which are shared with v4l.
207 */
52217195
DV
208 u32 color_formats;
209
b3c6c8bf
DV
210 /**
211 * @bus_formats: Pixel data format on the wire, somewhat redundant with
212 * @color_formats. Array of size @num_bus_formats encoded using
213 * MEDIA_BUS_FMT\_ defines shared with v4l and media drivers.
214 */
52217195 215 const u32 *bus_formats;
b3c6c8bf
DV
216 /**
217 * @num_bus_formats: Size of @bus_formats array.
218 */
52217195
DV
219 unsigned int num_bus_formats;
220
221#define DRM_BUS_FLAG_DE_LOW (1<<0)
222#define DRM_BUS_FLAG_DE_HIGH (1<<1)
223/* drive data on pos. edge */
224#define DRM_BUS_FLAG_PIXDATA_POSEDGE (1<<2)
225/* drive data on neg. edge */
226#define DRM_BUS_FLAG_PIXDATA_NEGEDGE (1<<3)
227
b3c6c8bf
DV
228 /**
229 * @bus_flags: Additional information (like pixel signal polarity) for
230 * the pixel data on the bus, using DRM_BUS_FLAGS\_ defines.
231 */
52217195
DV
232 u32 bus_flags;
233
2a272ca9
VS
234 /**
235 * @max_tmds_clock: Maximum TMDS clock rate supported by the
236 * sink in kHz. 0 means undefined.
237 */
238 int max_tmds_clock;
239
240 /**
241 * @dvi_dual: Dual-link DVI sink?
242 */
243 bool dvi_dual;
244
b3c6c8bf
DV
245 /**
246 * @edid_hdmi_dc_modes: Mask of supported hdmi deep color modes. Even
247 * more stuff redundant with @bus_formats.
248 */
52217195
DV
249 u8 edid_hdmi_dc_modes;
250
b3c6c8bf
DV
251 /**
252 * @cea_rev: CEA revision of the HDMI sink.
253 */
52217195 254 u8 cea_rev;
afa1c763
SS
255
256 /**
257 * @hdmi: advance features of a HDMI sink.
258 */
259 struct drm_hdmi_info hdmi;
52217195
DV
260};
261
b3c6c8bf
DV
262int drm_display_info_set_bus_formats(struct drm_display_info *info,
263 const u32 *formats,
264 unsigned int num_formats);
265
299a16b1
BB
266/**
267 * struct drm_tv_connector_state - TV connector related states
268 * @subconnector: selected subconnector
269 * @margins: left/right/top/bottom margins
270 * @mode: TV mode
271 * @brightness: brightness in percent
272 * @contrast: contrast in percent
273 * @flicker_reduction: flicker reduction in percent
274 * @overscan: overscan in percent
275 * @saturation: saturation in percent
276 * @hue: hue in percent
277 */
278struct drm_tv_connector_state {
279 enum drm_mode_subconnector subconnector;
280 struct {
281 unsigned int left;
282 unsigned int right;
283 unsigned int top;
284 unsigned int bottom;
285 } margins;
286 unsigned int mode;
287 unsigned int brightness;
288 unsigned int contrast;
289 unsigned int flicker_reduction;
290 unsigned int overscan;
291 unsigned int saturation;
292 unsigned int hue;
293};
294
52217195
DV
295/**
296 * struct drm_connector_state - mutable connector state
297 * @connector: backpointer to the connector
52217195
DV
298 * @best_encoder: can be used by helpers and drivers to select the encoder
299 * @state: backpointer to global drm_atomic_state
299a16b1 300 * @tv: TV connector state
52217195
DV
301 */
302struct drm_connector_state {
303 struct drm_connector *connector;
304
afb21ea6
DV
305 /**
306 * @crtc: CRTC to connect connector to, NULL if disabled.
307 *
308 * Do not change this directly, use drm_atomic_set_crtc_for_connector()
309 * instead.
310 */
311 struct drm_crtc *crtc;
52217195
DV
312
313 struct drm_encoder *best_encoder;
314
40ee6fbe
MN
315 /**
316 * @link_status: Connector link_status to keep track of whether link is
317 * GOOD or BAD to notify userspace if retraining is necessary.
318 */
319 enum drm_link_status link_status;
320
52217195 321 struct drm_atomic_state *state;
299a16b1
BB
322
323 struct drm_tv_connector_state tv;
52217195
DV
324};
325
326/**
327 * struct drm_connector_funcs - control connectors on a given device
328 *
329 * Each CRTC may have one or more connectors attached to it. The functions
330 * below allow the core DRM code to control connectors, enumerate available modes,
331 * etc.
332 */
333struct drm_connector_funcs {
334 /**
335 * @dpms:
336 *
337 * Legacy entry point to set the per-connector DPMS state. Legacy DPMS
338 * is exposed as a standard property on the connector, but diverted to
339 * this callback in the drm core. Note that atomic drivers don't
340 * implement the 4 level DPMS support on the connector any more, but
341 * instead only have an on/off "ACTIVE" property on the CRTC object.
342 *
343 * Drivers implementing atomic modeset should use
344 * drm_atomic_helper_connector_dpms() to implement this hook.
345 *
346 * RETURNS:
347 *
348 * 0 on success or a negative error code on failure.
349 */
350 int (*dpms)(struct drm_connector *connector, int mode);
351
352 /**
353 * @reset:
354 *
355 * Reset connector hardware and software state to off. This function isn't
356 * called by the core directly, only through drm_mode_config_reset().
357 * It's not a helper hook only for historical reasons.
358 *
359 * Atomic drivers can use drm_atomic_helper_connector_reset() to reset
360 * atomic state using this hook.
361 */
362 void (*reset)(struct drm_connector *connector);
363
364 /**
365 * @detect:
366 *
367 * Check to see if anything is attached to the connector. The parameter
368 * force is set to false whilst polling, true when checking the
369 * connector due to a user request. force can be used by the driver to
370 * avoid expensive, destructive operations during automated probing.
371 *
949f0886
LP
372 * This callback is optional, if not implemented the connector will be
373 * considered as always being attached.
374 *
52217195
DV
375 * FIXME:
376 *
377 * Note that this hook is only called by the probe helper. It's not in
378 * the helper library vtable purely for historical reasons. The only DRM
379 * core entry point to probe connector state is @fill_modes.
380 *
381 * RETURNS:
382 *
383 * drm_connector_status indicating the connector's status.
384 */
385 enum drm_connector_status (*detect)(struct drm_connector *connector,
386 bool force);
387
388 /**
389 * @force:
390 *
391 * This function is called to update internal encoder state when the
392 * connector is forced to a certain state by userspace, either through
393 * the sysfs interfaces or on the kernel cmdline. In that case the
394 * @detect callback isn't called.
395 *
396 * FIXME:
397 *
398 * Note that this hook is only called by the probe helper. It's not in
399 * the helper library vtable purely for historical reasons. The only DRM
400 * core entry point to probe connector state is @fill_modes.
401 */
402 void (*force)(struct drm_connector *connector);
403
404 /**
405 * @fill_modes:
406 *
407 * Entry point for output detection and basic mode validation. The
408 * driver should reprobe the output if needed (e.g. when hotplug
d574528a 409 * handling is unreliable), add all detected modes to &drm_connector.modes
52217195
DV
410 * and filter out any the device can't support in any configuration. It
411 * also needs to filter out any modes wider or higher than the
412 * parameters max_width and max_height indicate.
413 *
414 * The drivers must also prune any modes no longer valid from
d574528a
DV
415 * &drm_connector.modes. Furthermore it must update
416 * &drm_connector.status and &drm_connector.edid. If no EDID has been
417 * received for this output connector->edid must be NULL.
52217195
DV
418 *
419 * Drivers using the probe helpers should use
420 * drm_helper_probe_single_connector_modes() or
421 * drm_helper_probe_single_connector_modes_nomerge() to implement this
422 * function.
423 *
424 * RETURNS:
425 *
d574528a 426 * The number of modes detected and filled into &drm_connector.modes.
52217195
DV
427 */
428 int (*fill_modes)(struct drm_connector *connector, uint32_t max_width, uint32_t max_height);
429
430 /**
431 * @set_property:
432 *
433 * This is the legacy entry point to update a property attached to the
434 * connector.
435 *
436 * Drivers implementing atomic modeset should use
437 * drm_atomic_helper_connector_set_property() to implement this hook.
438 *
439 * This callback is optional if the driver does not support any legacy
440 * driver-private properties.
441 *
442 * RETURNS:
443 *
444 * 0 on success or a negative error code on failure.
445 */
446 int (*set_property)(struct drm_connector *connector, struct drm_property *property,
447 uint64_t val);
448
449 /**
450 * @late_register:
451 *
452 * This optional hook can be used to register additional userspace
453 * interfaces attached to the connector, light backlight control, i2c,
454 * DP aux or similar interfaces. It is called late in the driver load
455 * sequence from drm_connector_register() when registering all the
456 * core drm connector interfaces. Everything added from this callback
457 * should be unregistered in the early_unregister callback.
458 *
d574528a 459 * This is called while holding &drm_connector.mutex.
e73ab00e 460 *
52217195
DV
461 * Returns:
462 *
463 * 0 on success, or a negative error code on failure.
464 */
465 int (*late_register)(struct drm_connector *connector);
466
467 /**
468 * @early_unregister:
469 *
470 * This optional hook should be used to unregister the additional
471 * userspace interfaces attached to the connector from
621a9993 472 * late_register(). It is called from drm_connector_unregister(),
52217195
DV
473 * early in the driver unload sequence to disable userspace access
474 * before data structures are torndown.
e73ab00e 475 *
d574528a 476 * This is called while holding &drm_connector.mutex.
52217195
DV
477 */
478 void (*early_unregister)(struct drm_connector *connector);
479
480 /**
481 * @destroy:
482 *
483 * Clean up connector resources. This is called at driver unload time
484 * through drm_mode_config_cleanup(). It can also be called at runtime
485 * when a connector is being hot-unplugged for drivers that support
486 * connector hotplugging (e.g. DisplayPort MST).
487 */
488 void (*destroy)(struct drm_connector *connector);
489
490 /**
491 * @atomic_duplicate_state:
492 *
493 * Duplicate the current atomic state for this connector and return it.
621a9993 494 * The core and helpers guarantee that any atomic state duplicated with
52217195 495 * this hook and still owned by the caller (i.e. not transferred to the
d574528a
DV
496 * driver by calling &drm_mode_config_funcs.atomic_commit) will be
497 * cleaned up by calling the @atomic_destroy_state hook in this
498 * structure.
52217195 499 *
ea0dd85a 500 * Atomic drivers which don't subclass &struct drm_connector_state should use
52217195
DV
501 * drm_atomic_helper_connector_duplicate_state(). Drivers that subclass the
502 * state structure to extend it with driver-private state should use
503 * __drm_atomic_helper_connector_duplicate_state() to make sure shared state is
504 * duplicated in a consistent fashion across drivers.
505 *
d574528a 506 * It is an error to call this hook before &drm_connector.state has been
52217195
DV
507 * initialized correctly.
508 *
509 * NOTE:
510 *
511 * If the duplicate state references refcounted resources this hook must
512 * acquire a reference for each of them. The driver must release these
513 * references again in @atomic_destroy_state.
514 *
515 * RETURNS:
516 *
517 * Duplicated atomic state or NULL when the allocation failed.
518 */
519 struct drm_connector_state *(*atomic_duplicate_state)(struct drm_connector *connector);
520
521 /**
522 * @atomic_destroy_state:
523 *
524 * Destroy a state duplicated with @atomic_duplicate_state and release
525 * or unreference all resources it references
526 */
527 void (*atomic_destroy_state)(struct drm_connector *connector,
528 struct drm_connector_state *state);
529
530 /**
531 * @atomic_set_property:
532 *
533 * Decode a driver-private property value and store the decoded value
534 * into the passed-in state structure. Since the atomic core decodes all
535 * standardized properties (even for extensions beyond the core set of
536 * properties which might not be implemented by all drivers) this
537 * requires drivers to subclass the state structure.
538 *
539 * Such driver-private properties should really only be implemented for
540 * truly hardware/vendor specific state. Instead it is preferred to
541 * standardize atomic extension and decode the properties used to expose
542 * such an extension in the core.
543 *
544 * Do not call this function directly, use
545 * drm_atomic_connector_set_property() instead.
546 *
547 * This callback is optional if the driver does not support any
548 * driver-private atomic properties.
549 *
550 * NOTE:
551 *
552 * This function is called in the state assembly phase of atomic
553 * modesets, which can be aborted for any reason (including on
554 * userspace's request to just check whether a configuration would be
555 * possible). Drivers MUST NOT touch any persistent state (hardware or
556 * software) or data structures except the passed in @state parameter.
557 *
558 * Also since userspace controls in which order properties are set this
559 * function must not do any input validation (since the state update is
560 * incomplete and hence likely inconsistent). Instead any such input
561 * validation must be done in the various atomic_check callbacks.
562 *
563 * RETURNS:
564 *
565 * 0 if the property has been found, -EINVAL if the property isn't
566 * implemented by the driver (which shouldn't ever happen, the core only
567 * asks for properties attached to this connector). No other validation
568 * is allowed by the driver. The core already checks that the property
569 * value is within the range (integer, valid enum value, ...) the driver
570 * set when registering the property.
571 */
572 int (*atomic_set_property)(struct drm_connector *connector,
573 struct drm_connector_state *state,
574 struct drm_property *property,
575 uint64_t val);
576
577 /**
578 * @atomic_get_property:
579 *
580 * Reads out the decoded driver-private property. This is used to
581 * implement the GETCONNECTOR IOCTL.
582 *
583 * Do not call this function directly, use
584 * drm_atomic_connector_get_property() instead.
585 *
586 * This callback is optional if the driver does not support any
587 * driver-private atomic properties.
588 *
589 * RETURNS:
590 *
591 * 0 on success, -EINVAL if the property isn't implemented by the
592 * driver (which shouldn't ever happen, the core only asks for
593 * properties attached to this connector).
594 */
595 int (*atomic_get_property)(struct drm_connector *connector,
596 const struct drm_connector_state *state,
597 struct drm_property *property,
598 uint64_t *val);
fceffb32
RC
599
600 /**
601 * @atomic_print_state:
602 *
ea0dd85a 603 * If driver subclasses &struct drm_connector_state, it should implement
fceffb32
RC
604 * this optional hook for printing additional driver specific state.
605 *
606 * Do not call this directly, use drm_atomic_connector_print_state()
607 * instead.
608 */
609 void (*atomic_print_state)(struct drm_printer *p,
610 const struct drm_connector_state *state);
52217195
DV
611};
612
613/* mode specified on the command line */
614struct drm_cmdline_mode {
615 bool specified;
616 bool refresh_specified;
617 bool bpp_specified;
618 int xres, yres;
619 int bpp;
620 int refresh;
621 bool rb;
622 bool interlace;
623 bool cvt;
624 bool margins;
625 enum drm_connector_force force;
626};
627
628/**
629 * struct drm_connector - central DRM connector control structure
630 * @dev: parent DRM device
631 * @kdev: kernel device for sysfs attributes
632 * @attr: sysfs attributes
633 * @head: list management
634 * @base: base KMS object
635 * @name: human readable name, can be overwritten by the driver
636 * @connector_type: one of the DRM_MODE_CONNECTOR_<foo> types from drm_mode.h
637 * @connector_type_id: index into connector type enum
638 * @interlace_allowed: can this connector handle interlaced modes?
639 * @doublescan_allowed: can this connector handle doublescan?
640 * @stereo_allowed: can this connector handle stereo modes?
52217195
DV
641 * @funcs: connector control functions
642 * @edid_blob_ptr: DRM property containing EDID if present
643 * @properties: property tracking for this connector
52217195
DV
644 * @dpms: current dpms state
645 * @helper_private: mid-layer private data
646 * @cmdline_mode: mode line parsed from the kernel cmdline for this connector
647 * @force: a DRM_FORCE_<foo> state for forced mode sets
648 * @override_edid: has the EDID been overwritten through debugfs for testing?
649 * @encoder_ids: valid encoders for this connector
650 * @encoder: encoder driving this connector, if any
651 * @eld: EDID-like data, if present
52217195
DV
652 * @latency_present: AV delay info from ELD, if found
653 * @video_latency: video latency info from ELD, if found
654 * @audio_latency: audio latency info from ELD, if found
655 * @null_edid_counter: track sinks that give us all zeros for the EDID
656 * @bad_edid_counter: track sinks that give us an EDID with invalid checksum
657 * @edid_corrupt: indicates whether the last read EDID was corrupt
658 * @debugfs_entry: debugfs directory for this connector
659 * @state: current atomic state for this connector
660 * @has_tile: is this connector connected to a tiled monitor
661 * @tile_group: tile group for the connected monitor
662 * @tile_is_single_monitor: whether the tile is one monitor housing
663 * @num_h_tile: number of horizontal tiles in the tile group
664 * @num_v_tile: number of vertical tiles in the tile group
665 * @tile_h_loc: horizontal location of this tile
666 * @tile_v_loc: vertical location of this tile
667 * @tile_h_size: horizontal size of this tile.
668 * @tile_v_size: vertical size of this tile.
669 *
670 * Each connector may be connected to one or more CRTCs, or may be clonable by
671 * another connector if they can share a CRTC. Each connector also has a specific
672 * position in the broader display (referred to as a 'screen' though it could
673 * span multiple monitors).
674 */
675struct drm_connector {
676 struct drm_device *dev;
677 struct device *kdev;
678 struct device_attribute *attr;
679 struct list_head head;
680
681 struct drm_mode_object base;
682
683 char *name;
684
e73ab00e
DV
685 /**
686 * @mutex: Lock for general connector state, but currently only protects
d574528a
DV
687 * @registered. Most of the connector state is still protected by
688 * &drm_mode_config.mutex.
e73ab00e
DV
689 */
690 struct mutex mutex;
691
52217195
DV
692 /**
693 * @index: Compacted connector index, which matches the position inside
694 * the mode_config.list for drivers not supporting hot-add/removing. Can
695 * be used as an array index. It is invariant over the lifetime of the
696 * connector.
697 */
698 unsigned index;
699
700 int connector_type;
701 int connector_type_id;
702 bool interlace_allowed;
703 bool doublescan_allowed;
704 bool stereo_allowed;
e73ab00e
DV
705 /**
706 * @registered: Is this connector exposed (registered) with userspace?
707 * Protected by @mutex.
708 */
52217195 709 bool registered;
91eefc05
DV
710
711 /**
712 * @modes:
713 * Modes available on this connector (from fill_modes() + user).
d574528a 714 * Protected by &drm_mode_config.mutex.
91eefc05 715 */
d574528a 716 struct list_head modes;
52217195 717
91eefc05
DV
718 /**
719 * @status:
720 * One of the drm_connector_status enums (connected, not, or unknown).
d574528a 721 * Protected by &drm_mode_config.mutex.
91eefc05 722 */
52217195
DV
723 enum drm_connector_status status;
724
91eefc05
DV
725 /**
726 * @probed_modes:
727 * These are modes added by probing with DDC or the BIOS, before
d574528a
DV
728 * filtering is applied. Used by the probe helpers. Protected by
729 * &drm_mode_config.mutex.
91eefc05 730 */
52217195
DV
731 struct list_head probed_modes;
732
ae2a6da8
DV
733 /**
734 * @display_info: Display information is filled from EDID information
735 * when a display is detected. For non hot-pluggable displays such as
736 * flat panels in embedded systems, the driver should initialize the
d574528a
DV
737 * &drm_display_info.width_mm and &drm_display_info.height_mm fields
738 * with the physical size of the display.
91eefc05 739 *
d574528a 740 * Protected by &drm_mode_config.mutex.
ae2a6da8 741 */
52217195
DV
742 struct drm_display_info display_info;
743 const struct drm_connector_funcs *funcs;
744
745 struct drm_property_blob *edid_blob_ptr;
746 struct drm_object_properties properties;
747
748 /**
749 * @path_blob_ptr:
750 *
751 * DRM blob property data for the DP MST path property.
752 */
753 struct drm_property_blob *path_blob_ptr;
754
755 /**
756 * @tile_blob_ptr:
757 *
758 * DRM blob property data for the tile property (used mostly by DP MST).
759 * This is meant for screens which are driven through separate display
760 * pipelines represented by &drm_crtc, which might not be running with
761 * genlocked clocks. For tiled panels which are genlocked, like
762 * dual-link LVDS or dual-link DSI, the driver should try to not expose
763 * the tiling and virtualize both &drm_crtc and &drm_plane if needed.
764 */
765 struct drm_property_blob *tile_blob_ptr;
766
767/* should we poll this connector for connects and disconnects */
768/* hot plug detectable */
769#define DRM_CONNECTOR_POLL_HPD (1 << 0)
770/* poll for connections */
771#define DRM_CONNECTOR_POLL_CONNECT (1 << 1)
772/* can cleanly poll for disconnections without flickering the screen */
773/* DACs should rarely do this without a lot of testing */
774#define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2)
775
ae2a6da8
DV
776 /**
777 * @polled:
778 *
779 * Connector polling mode, a combination of
780 *
781 * DRM_CONNECTOR_POLL_HPD
782 * The connector generates hotplug events and doesn't need to be
783 * periodically polled. The CONNECT and DISCONNECT flags must not
784 * be set together with the HPD flag.
785 *
786 * DRM_CONNECTOR_POLL_CONNECT
787 * Periodically poll the connector for connection.
788 *
789 * DRM_CONNECTOR_POLL_DISCONNECT
790 * Periodically poll the connector for disconnection.
791 *
792 * Set to 0 for connectors that don't support connection status
793 * discovery.
794 */
795 uint8_t polled;
52217195
DV
796
797 /* requested DPMS state */
798 int dpms;
799
800 const struct drm_connector_helper_funcs *helper_private;
801
802 /* forced on connector */
803 struct drm_cmdline_mode cmdline_mode;
804 enum drm_connector_force force;
805 bool override_edid;
806
807#define DRM_CONNECTOR_MAX_ENCODER 3
808 uint32_t encoder_ids[DRM_CONNECTOR_MAX_ENCODER];
809 struct drm_encoder *encoder; /* currently active encoder */
810
811#define MAX_ELD_BYTES 128
812 /* EDID bits */
813 uint8_t eld[MAX_ELD_BYTES];
52217195
DV
814 bool latency_present[2];
815 int video_latency[2]; /* [0]: progressive, [1]: interlaced */
816 int audio_latency[2];
817 int null_edid_counter; /* needed to workaround some HW bugs where we get all 0s */
818 unsigned bad_edid_counter;
819
820 /* Flag for raw EDID header corruption - used in Displayport
821 * compliance testing - * Displayport Link CTS Core 1.2 rev1.1 4.2.2.6
822 */
823 bool edid_corrupt;
824
825 struct dentry *debugfs_entry;
826
827 struct drm_connector_state *state;
828
829 /* DisplayID bits */
830 bool has_tile;
831 struct drm_tile_group *tile_group;
832 bool tile_is_single_monitor;
833
834 uint8_t num_h_tile, num_v_tile;
835 uint8_t tile_h_loc, tile_v_loc;
836 uint16_t tile_h_size, tile_v_size;
837};
838
839#define obj_to_connector(x) container_of(x, struct drm_connector, base)
840
841int drm_connector_init(struct drm_device *dev,
842 struct drm_connector *connector,
843 const struct drm_connector_funcs *funcs,
844 int connector_type);
845int drm_connector_register(struct drm_connector *connector);
846void drm_connector_unregister(struct drm_connector *connector);
847int drm_mode_connector_attach_encoder(struct drm_connector *connector,
848 struct drm_encoder *encoder);
849
850void drm_connector_cleanup(struct drm_connector *connector);
851static inline unsigned drm_connector_index(struct drm_connector *connector)
852{
853 return connector->index;
854}
855
856/**
857 * drm_connector_lookup - lookup connector object
858 * @dev: DRM device
859 * @id: connector object id
860 *
861 * This function looks up the connector object specified by id
862 * add takes a reference to it.
863 */
864static inline struct drm_connector *drm_connector_lookup(struct drm_device *dev,
865 uint32_t id)
866{
867 struct drm_mode_object *mo;
868 mo = drm_mode_object_find(dev, id, DRM_MODE_OBJECT_CONNECTOR);
869 return mo ? obj_to_connector(mo) : NULL;
870}
871
872/**
ad093607
TR
873 * drm_connector_get - acquire a connector reference
874 * @connector: DRM connector
52217195
DV
875 *
876 * This function increments the connector's refcount.
877 */
ad093607
TR
878static inline void drm_connector_get(struct drm_connector *connector)
879{
880 drm_mode_object_get(&connector->base);
881}
882
883/**
884 * drm_connector_put - release a connector reference
885 * @connector: DRM connector
886 *
887 * This function decrements the connector's reference count and frees the
888 * object if the reference count drops to zero.
889 */
890static inline void drm_connector_put(struct drm_connector *connector)
891{
892 drm_mode_object_put(&connector->base);
893}
894
895/**
896 * drm_connector_reference - acquire a connector reference
897 * @connector: DRM connector
898 *
899 * This is a compatibility alias for drm_connector_get() and should not be
900 * used by new code.
901 */
52217195
DV
902static inline void drm_connector_reference(struct drm_connector *connector)
903{
ad093607 904 drm_connector_get(connector);
52217195
DV
905}
906
907/**
ad093607
TR
908 * drm_connector_unreference - release a connector reference
909 * @connector: DRM connector
52217195 910 *
ad093607
TR
911 * This is a compatibility alias for drm_connector_put() and should not be
912 * used by new code.
52217195
DV
913 */
914static inline void drm_connector_unreference(struct drm_connector *connector)
915{
ad093607 916 drm_connector_put(connector);
52217195
DV
917}
918
919const char *drm_get_connector_status_name(enum drm_connector_status status);
920const char *drm_get_subpixel_order_name(enum subpixel_order order);
921const char *drm_get_dpms_name(int val);
922const char *drm_get_dvi_i_subconnector_name(int val);
923const char *drm_get_dvi_i_select_name(int val);
924const char *drm_get_tv_subconnector_name(int val);
925const char *drm_get_tv_select_name(int val);
926
927int drm_mode_create_dvi_i_properties(struct drm_device *dev);
928int drm_mode_create_tv_properties(struct drm_device *dev,
929 unsigned int num_modes,
930 const char * const modes[]);
931int drm_mode_create_scaling_mode_property(struct drm_device *dev);
932int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
933int drm_mode_create_suggested_offset_properties(struct drm_device *dev);
934
935int drm_mode_connector_set_path_property(struct drm_connector *connector,
936 const char *path);
937int drm_mode_connector_set_tile_property(struct drm_connector *connector);
938int drm_mode_connector_update_edid_property(struct drm_connector *connector,
939 const struct edid *edid);
40ee6fbe
MN
940void drm_mode_connector_set_link_status_property(struct drm_connector *connector,
941 uint64_t link_status);
afb21ea6 942
9498c19b
DV
943/**
944 * struct drm_tile_group - Tile group metadata
945 * @refcount: reference count
946 * @dev: DRM device
947 * @id: tile group id exposed to userspace
948 * @group_data: Sink-private data identifying this group
949 *
950 * @group_data corresponds to displayid vend/prod/serial for external screens
951 * with an EDID.
952 */
953struct drm_tile_group {
954 struct kref refcount;
955 struct drm_device *dev;
956 int id;
957 u8 group_data[8];
958};
959
960struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
961 char topology[8]);
962struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
963 char topology[8]);
964void drm_mode_put_tile_group(struct drm_device *dev,
965 struct drm_tile_group *tg);
966
afb21ea6
DV
967/**
968 * drm_for_each_connector - iterate over all connectors
969 * @connector: the loop cursor
970 * @dev: the DRM device
971 *
972 * Iterate over all connectors of @dev.
613051da
DV
973 *
974 * WARNING:
975 *
976 * This iterator is not safe against hotadd/removal of connectors and is
977 * deprecated. Use drm_for_each_connector_iter() instead.
afb21ea6
DV
978 */
979#define drm_for_each_connector(connector, dev) \
347e8903 980 list_for_each_entry(connector, &(dev)->mode_config.connector_list, head)
afb21ea6 981
613051da
DV
982/**
983 * struct drm_connector_list_iter - connector_list iterator
984 *
985 * This iterator tracks state needed to be able to walk the connector_list
986 * within struct drm_mode_config. Only use together with
b982dab1 987 * drm_connector_list_iter_begin(), drm_connector_list_iter_end() and
613051da
DV
988 * drm_connector_list_iter_next() respectively the convenience macro
989 * drm_for_each_connector_iter().
990 */
991struct drm_connector_list_iter {
992/* private: */
993 struct drm_device *dev;
994 struct drm_connector *conn;
995};
996
b982dab1
TR
997void drm_connector_list_iter_begin(struct drm_device *dev,
998 struct drm_connector_list_iter *iter);
613051da
DV
999struct drm_connector *
1000drm_connector_list_iter_next(struct drm_connector_list_iter *iter);
b982dab1 1001void drm_connector_list_iter_end(struct drm_connector_list_iter *iter);
613051da
DV
1002
1003/**
1004 * drm_for_each_connector_iter - connector_list iterator macro
ea0dd85a
DV
1005 * @connector: &struct drm_connector pointer used as cursor
1006 * @iter: &struct drm_connector_list_iter
613051da
DV
1007 *
1008 * Note that @connector is only valid within the list body, if you want to use
b982dab1
TR
1009 * @connector after calling drm_connector_list_iter_end() then you need to grab
1010 * your own reference first using drm_connector_begin().
613051da
DV
1011 */
1012#define drm_for_each_connector_iter(connector, iter) \
1013 while ((connector = drm_connector_list_iter_next(iter)))
1014
52217195 1015#endif