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