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