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