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