2 * Copyright (c) 2016 Intel Corporation
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.
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
23 #ifndef __DRM_CONNECTOR_H__
24 #define __DRM_CONNECTOR_H__
26 #include <linux/list.h>
27 #include <linux/ctype.h>
28 #include <linux/hdmi.h>
29 #include <drm/drm_mode_object.h>
31 #include <uapi/drm/drm_mode.h>
33 struct drm_connector_helper_funcs
;
34 struct drm_modeset_acquire_ctx
;
39 struct drm_property_blob
;
43 enum drm_connector_force
{
44 DRM_FORCE_UNSPECIFIED
,
46 DRM_FORCE_ON
, /* force on analog part normally */
47 DRM_FORCE_ON_DIGITAL
, /* for DVI-I use digital connector */
51 * enum drm_connector_status - status for a &drm_connector
53 * This enum is used to track the connector status. There are no separate
54 * #defines for the uapi!
56 enum drm_connector_status
{
58 * @connector_status_connected: The connector is definitely connected to
59 * a sink device, and can be enabled.
61 connector_status_connected
= 1,
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.
69 connector_status_disconnected
= 2,
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.
80 connector_status_unknown
= 3,
85 SubPixelHorizontalRGB
,
86 SubPixelHorizontalBGR
,
94 * struct drm_scrambling: sink's scrambling support.
96 struct drm_scrambling
{
98 * @supported: scrambling supported for rates > 340 Mhz.
102 * @low_rates: scrambling supported for rates <= 340 Mhz.
108 * struct drm_scdc - Information about scdc capabilities of a HDMI 2.0 sink
110 * Provides SCDC register support and capabilities related information on a
111 * HDMI 2.0 sink. In case of a HDMI 1.4 sink, all parameter must be 0.
115 * @supported: status control & data channel present.
119 * @read_request: sink is capable of generating scdc read request.
123 * @scrambling: sink's scrambling capabilities
125 struct drm_scrambling scrambling
;
130 * struct drm_hdmi_info - runtime information about the connected HDMI sink
132 * Describes if a given display supports advanced HDMI 2.0 features.
133 * This information is available in CEA-861-F extension blocks (like HF-VSDB).
135 struct drm_hdmi_info
{
136 /** @scdc: sink's scdc support and capabilities */
137 struct drm_scdc scdc
;
140 * @y420_vdb_modes: bitmap of modes which can support ycbcr420
141 * output only (not normal RGB/YCBCR444/422 outputs). There are total
142 * 107 VICs defined by CEA-861-F spec, so the size is 128 bits to map
145 unsigned long y420_vdb_modes
[BITS_TO_LONGS(128)];
148 * @y420_cmdb_modes: bitmap of modes which can support ycbcr420
149 * output also, along with normal HDMI outputs. There are total 107
150 * VICs defined by CEA-861-F spec, so the size is 128 bits to map upto
153 unsigned long y420_cmdb_modes
[BITS_TO_LONGS(128)];
155 /** @y420_cmdb_map: bitmap of SVD index, to extraxt vcb modes */
158 /** @y420_dc_modes: bitmap of deep color support index */
163 * enum drm_link_status - connector's link_status property value
165 * This enum is used as the connector's link status property value.
166 * It is set to the values defined in uapi.
168 * @DRM_LINK_STATUS_GOOD: DP Link is Good as a result of successful
170 * @DRM_LINK_STATUS_BAD: DP Link is BAD as a result of link training
173 enum drm_link_status
{
174 DRM_LINK_STATUS_GOOD
= DRM_MODE_LINK_STATUS_GOOD
,
175 DRM_LINK_STATUS_BAD
= DRM_MODE_LINK_STATUS_BAD
,
179 * struct drm_display_info - runtime data about the connected sink
181 * Describes a given display (e.g. CRT or flat panel) and its limitations. For
182 * fixed display sinks like built-in panels there's not much difference between
183 * this and &struct drm_connector. But for sinks with a real cable this
184 * structure is meant to describe all the things at the other end of the cable.
186 * For sinks which provide an EDID this can be filled out by calling
187 * drm_add_edid_modes().
189 struct drm_display_info
{
191 * @name: Name of the display.
193 char name
[DRM_DISPLAY_INFO_LEN
];
196 * @width_mm: Physical width in mm.
198 unsigned int width_mm
;
200 * @height_mm: Physical height in mm.
202 unsigned int height_mm
;
205 * @pixel_clock: Maximum pixel clock supported by the sink, in units of
206 * 100Hz. This mismatches the clock in &drm_display_mode (which is in
207 * kHZ), because that's what the EDID uses as base unit.
209 unsigned int pixel_clock
;
211 * @bpc: Maximum bits per color channel. Used by HDMI and DP outputs.
216 * @subpixel_order: Subpixel order of LCD panels.
218 enum subpixel_order subpixel_order
;
220 #define DRM_COLOR_FORMAT_RGB444 (1<<0)
221 #define DRM_COLOR_FORMAT_YCRCB444 (1<<1)
222 #define DRM_COLOR_FORMAT_YCRCB422 (1<<2)
223 #define DRM_COLOR_FORMAT_YCRCB420 (1<<3)
226 * @color_formats: HDMI Color formats, selects between RGB and YCrCb
227 * modes. Used DRM_COLOR_FORMAT\_ defines, which are _not_ the same ones
228 * as used to describe the pixel format in framebuffers, and also don't
229 * match the formats in @bus_formats which are shared with v4l.
234 * @bus_formats: Pixel data format on the wire, somewhat redundant with
235 * @color_formats. Array of size @num_bus_formats encoded using
236 * MEDIA_BUS_FMT\_ defines shared with v4l and media drivers.
238 const u32
*bus_formats
;
240 * @num_bus_formats: Size of @bus_formats array.
242 unsigned int num_bus_formats
;
244 #define DRM_BUS_FLAG_DE_LOW (1<<0)
245 #define DRM_BUS_FLAG_DE_HIGH (1<<1)
246 /* drive data on pos. edge */
247 #define DRM_BUS_FLAG_PIXDATA_POSEDGE (1<<2)
248 /* drive data on neg. edge */
249 #define DRM_BUS_FLAG_PIXDATA_NEGEDGE (1<<3)
250 /* data is transmitted MSB to LSB on the bus */
251 #define DRM_BUS_FLAG_DATA_MSB_TO_LSB (1<<4)
252 /* data is transmitted LSB to MSB on the bus */
253 #define DRM_BUS_FLAG_DATA_LSB_TO_MSB (1<<5)
256 * @bus_flags: Additional information (like pixel signal polarity) for
257 * the pixel data on the bus, using DRM_BUS_FLAGS\_ defines.
262 * @max_tmds_clock: Maximum TMDS clock rate supported by the
263 * sink in kHz. 0 means undefined.
268 * @dvi_dual: Dual-link DVI sink?
273 * @edid_hdmi_dc_modes: Mask of supported hdmi deep color modes. Even
274 * more stuff redundant with @bus_formats.
276 u8 edid_hdmi_dc_modes
;
279 * @cea_rev: CEA revision of the HDMI sink.
284 * @hdmi: advance features of a HDMI sink.
286 struct drm_hdmi_info hdmi
;
289 int drm_display_info_set_bus_formats(struct drm_display_info
*info
,
291 unsigned int num_formats
);
294 * struct drm_tv_connector_state - TV connector related states
295 * @subconnector: selected subconnector
296 * @margins: left/right/top/bottom margins
298 * @brightness: brightness in percent
299 * @contrast: contrast in percent
300 * @flicker_reduction: flicker reduction in percent
301 * @overscan: overscan in percent
302 * @saturation: saturation in percent
303 * @hue: hue in percent
305 struct drm_tv_connector_state
{
306 enum drm_mode_subconnector subconnector
;
314 unsigned int brightness
;
315 unsigned int contrast
;
316 unsigned int flicker_reduction
;
317 unsigned int overscan
;
318 unsigned int saturation
;
323 * struct drm_connector_state - mutable connector state
324 * @connector: backpointer to the connector
325 * @best_encoder: can be used by helpers and drivers to select the encoder
326 * @state: backpointer to global drm_atomic_state
327 * @tv: TV connector state
329 struct drm_connector_state
{
330 struct drm_connector
*connector
;
333 * @crtc: CRTC to connect connector to, NULL if disabled.
335 * Do not change this directly, use drm_atomic_set_crtc_for_connector()
338 struct drm_crtc
*crtc
;
340 struct drm_encoder
*best_encoder
;
343 * @link_status: Connector link_status to keep track of whether link is
344 * GOOD or BAD to notify userspace if retraining is necessary.
346 enum drm_link_status link_status
;
348 struct drm_atomic_state
*state
;
350 struct drm_tv_connector_state tv
;
353 * @picture_aspect_ratio: Connector property to control the
354 * HDMI infoframe aspect ratio setting.
356 * The %DRM_MODE_PICTURE_ASPECT_\* values much match the
357 * values for &enum hdmi_picture_aspect
359 enum hdmi_picture_aspect picture_aspect_ratio
;
362 * @scaling_mode: Connector property to control the
363 * upscaling, mostly used for built-in panels.
365 unsigned int scaling_mode
;
369 * struct drm_connector_funcs - control connectors on a given device
371 * Each CRTC may have one or more connectors attached to it. The functions
372 * below allow the core DRM code to control connectors, enumerate available modes,
375 struct drm_connector_funcs
{
379 * Legacy entry point to set the per-connector DPMS state. Legacy DPMS
380 * is exposed as a standard property on the connector, but diverted to
381 * this callback in the drm core. Note that atomic drivers don't
382 * implement the 4 level DPMS support on the connector any more, but
383 * instead only have an on/off "ACTIVE" property on the CRTC object.
385 * This hook is not used by atomic drivers, remapping of the legacy DPMS
386 * property is entirely handled in the DRM core.
390 * 0 on success or a negative error code on failure.
392 int (*dpms
)(struct drm_connector
*connector
, int mode
);
397 * Reset connector hardware and software state to off. This function isn't
398 * called by the core directly, only through drm_mode_config_reset().
399 * It's not a helper hook only for historical reasons.
401 * Atomic drivers can use drm_atomic_helper_connector_reset() to reset
402 * atomic state using this hook.
404 void (*reset
)(struct drm_connector
*connector
);
409 * Check to see if anything is attached to the connector. The parameter
410 * force is set to false whilst polling, true when checking the
411 * connector due to a user request. force can be used by the driver to
412 * avoid expensive, destructive operations during automated probing.
414 * This callback is optional, if not implemented the connector will be
415 * considered as always being attached.
419 * Note that this hook is only called by the probe helper. It's not in
420 * the helper library vtable purely for historical reasons. The only DRM
421 * core entry point to probe connector state is @fill_modes.
423 * Note that the helper library will already hold
424 * &drm_mode_config.connection_mutex. Drivers which need to grab additional
425 * locks to avoid races with concurrent modeset changes need to use
426 * &drm_connector_helper_funcs.detect_ctx instead.
430 * drm_connector_status indicating the connector's status.
432 enum drm_connector_status (*detect
)(struct drm_connector
*connector
,
438 * This function is called to update internal encoder state when the
439 * connector is forced to a certain state by userspace, either through
440 * the sysfs interfaces or on the kernel cmdline. In that case the
441 * @detect callback isn't called.
445 * Note that this hook is only called by the probe helper. It's not in
446 * the helper library vtable purely for historical reasons. The only DRM
447 * core entry point to probe connector state is @fill_modes.
449 void (*force
)(struct drm_connector
*connector
);
454 * Entry point for output detection and basic mode validation. The
455 * driver should reprobe the output if needed (e.g. when hotplug
456 * handling is unreliable), add all detected modes to &drm_connector.modes
457 * and filter out any the device can't support in any configuration. It
458 * also needs to filter out any modes wider or higher than the
459 * parameters max_width and max_height indicate.
461 * The drivers must also prune any modes no longer valid from
462 * &drm_connector.modes. Furthermore it must update
463 * &drm_connector.status and &drm_connector.edid. If no EDID has been
464 * received for this output connector->edid must be NULL.
466 * Drivers using the probe helpers should use
467 * drm_helper_probe_single_connector_modes() or
468 * drm_helper_probe_single_connector_modes_nomerge() to implement this
473 * The number of modes detected and filled into &drm_connector.modes.
475 int (*fill_modes
)(struct drm_connector
*connector
, uint32_t max_width
, uint32_t max_height
);
480 * This is the legacy entry point to update a property attached to the
483 * This callback is optional if the driver does not support any legacy
484 * driver-private properties. For atomic drivers it is not used because
485 * property handling is done entirely in the DRM core.
489 * 0 on success or a negative error code on failure.
491 int (*set_property
)(struct drm_connector
*connector
, struct drm_property
*property
,
497 * This optional hook can be used to register additional userspace
498 * interfaces attached to the connector, light backlight control, i2c,
499 * DP aux or similar interfaces. It is called late in the driver load
500 * sequence from drm_connector_register() when registering all the
501 * core drm connector interfaces. Everything added from this callback
502 * should be unregistered in the early_unregister callback.
504 * This is called while holding &drm_connector.mutex.
508 * 0 on success, or a negative error code on failure.
510 int (*late_register
)(struct drm_connector
*connector
);
515 * This optional hook should be used to unregister the additional
516 * userspace interfaces attached to the connector from
517 * late_register(). It is called from drm_connector_unregister(),
518 * early in the driver unload sequence to disable userspace access
519 * before data structures are torndown.
521 * This is called while holding &drm_connector.mutex.
523 void (*early_unregister
)(struct drm_connector
*connector
);
528 * Clean up connector resources. This is called at driver unload time
529 * through drm_mode_config_cleanup(). It can also be called at runtime
530 * when a connector is being hot-unplugged for drivers that support
531 * connector hotplugging (e.g. DisplayPort MST).
533 void (*destroy
)(struct drm_connector
*connector
);
536 * @atomic_duplicate_state:
538 * Duplicate the current atomic state for this connector and return it.
539 * The core and helpers guarantee that any atomic state duplicated with
540 * this hook and still owned by the caller (i.e. not transferred to the
541 * driver by calling &drm_mode_config_funcs.atomic_commit) will be
542 * cleaned up by calling the @atomic_destroy_state hook in this
545 * Atomic drivers which don't subclass &struct drm_connector_state should use
546 * drm_atomic_helper_connector_duplicate_state(). Drivers that subclass the
547 * state structure to extend it with driver-private state should use
548 * __drm_atomic_helper_connector_duplicate_state() to make sure shared state is
549 * duplicated in a consistent fashion across drivers.
551 * It is an error to call this hook before &drm_connector.state has been
552 * initialized correctly.
556 * If the duplicate state references refcounted resources this hook must
557 * acquire a reference for each of them. The driver must release these
558 * references again in @atomic_destroy_state.
562 * Duplicated atomic state or NULL when the allocation failed.
564 struct drm_connector_state
*(*atomic_duplicate_state
)(struct drm_connector
*connector
);
567 * @atomic_destroy_state:
569 * Destroy a state duplicated with @atomic_duplicate_state and release
570 * or unreference all resources it references
572 void (*atomic_destroy_state
)(struct drm_connector
*connector
,
573 struct drm_connector_state
*state
);
576 * @atomic_set_property:
578 * Decode a driver-private property value and store the decoded value
579 * into the passed-in state structure. Since the atomic core decodes all
580 * standardized properties (even for extensions beyond the core set of
581 * properties which might not be implemented by all drivers) this
582 * requires drivers to subclass the state structure.
584 * Such driver-private properties should really only be implemented for
585 * truly hardware/vendor specific state. Instead it is preferred to
586 * standardize atomic extension and decode the properties used to expose
587 * such an extension in the core.
589 * Do not call this function directly, use
590 * drm_atomic_connector_set_property() instead.
592 * This callback is optional if the driver does not support any
593 * driver-private atomic properties.
597 * This function is called in the state assembly phase of atomic
598 * modesets, which can be aborted for any reason (including on
599 * userspace's request to just check whether a configuration would be
600 * possible). Drivers MUST NOT touch any persistent state (hardware or
601 * software) or data structures except the passed in @state parameter.
603 * Also since userspace controls in which order properties are set this
604 * function must not do any input validation (since the state update is
605 * incomplete and hence likely inconsistent). Instead any such input
606 * validation must be done in the various atomic_check callbacks.
610 * 0 if the property has been found, -EINVAL if the property isn't
611 * implemented by the driver (which shouldn't ever happen, the core only
612 * asks for properties attached to this connector). No other validation
613 * is allowed by the driver. The core already checks that the property
614 * value is within the range (integer, valid enum value, ...) the driver
615 * set when registering the property.
617 int (*atomic_set_property
)(struct drm_connector
*connector
,
618 struct drm_connector_state
*state
,
619 struct drm_property
*property
,
623 * @atomic_get_property:
625 * Reads out the decoded driver-private property. This is used to
626 * implement the GETCONNECTOR IOCTL.
628 * Do not call this function directly, use
629 * drm_atomic_connector_get_property() instead.
631 * This callback is optional if the driver does not support any
632 * driver-private atomic properties.
636 * 0 on success, -EINVAL if the property isn't implemented by the
637 * driver (which shouldn't ever happen, the core only asks for
638 * properties attached to this connector).
640 int (*atomic_get_property
)(struct drm_connector
*connector
,
641 const struct drm_connector_state
*state
,
642 struct drm_property
*property
,
646 * @atomic_print_state:
648 * If driver subclasses &struct drm_connector_state, it should implement
649 * this optional hook for printing additional driver specific state.
651 * Do not call this directly, use drm_atomic_connector_print_state()
654 void (*atomic_print_state
)(struct drm_printer
*p
,
655 const struct drm_connector_state
*state
);
658 /* mode specified on the command line */
659 struct drm_cmdline_mode
{
661 bool refresh_specified
;
670 enum drm_connector_force force
;
674 * struct drm_connector - central DRM connector control structure
675 * @dev: parent DRM device
676 * @kdev: kernel device for sysfs attributes
677 * @attr: sysfs attributes
678 * @head: list management
679 * @base: base KMS object
680 * @name: human readable name, can be overwritten by the driver
681 * @connector_type: one of the DRM_MODE_CONNECTOR_<foo> types from drm_mode.h
682 * @connector_type_id: index into connector type enum
683 * @interlace_allowed: can this connector handle interlaced modes?
684 * @doublescan_allowed: can this connector handle doublescan?
685 * @stereo_allowed: can this connector handle stereo modes?
686 * @funcs: connector control functions
687 * @edid_blob_ptr: DRM property containing EDID if present
688 * @properties: property tracking for this connector
689 * @dpms: current dpms state
690 * @helper_private: mid-layer private data
691 * @cmdline_mode: mode line parsed from the kernel cmdline for this connector
692 * @force: a DRM_FORCE_<foo> state for forced mode sets
693 * @override_edid: has the EDID been overwritten through debugfs for testing?
694 * @encoder_ids: valid encoders for this connector
695 * @encoder: encoder driving this connector, if any
696 * @eld: EDID-like data, if present
697 * @latency_present: AV delay info from ELD, if found
698 * @video_latency: video latency info from ELD, if found
699 * @audio_latency: audio latency info from ELD, if found
700 * @null_edid_counter: track sinks that give us all zeros for the EDID
701 * @bad_edid_counter: track sinks that give us an EDID with invalid checksum
702 * @edid_corrupt: indicates whether the last read EDID was corrupt
703 * @debugfs_entry: debugfs directory for this connector
704 * @has_tile: is this connector connected to a tiled monitor
705 * @tile_group: tile group for the connected monitor
706 * @tile_is_single_monitor: whether the tile is one monitor housing
707 * @num_h_tile: number of horizontal tiles in the tile group
708 * @num_v_tile: number of vertical tiles in the tile group
709 * @tile_h_loc: horizontal location of this tile
710 * @tile_v_loc: vertical location of this tile
711 * @tile_h_size: horizontal size of this tile.
712 * @tile_v_size: vertical size of this tile.
713 * @scaling_mode_property: Optional atomic property to control the upscaling.
715 * Each connector may be connected to one or more CRTCs, or may be clonable by
716 * another connector if they can share a CRTC. Each connector also has a specific
717 * position in the broader display (referred to as a 'screen' though it could
718 * span multiple monitors).
720 struct drm_connector
{
721 struct drm_device
*dev
;
723 struct device_attribute
*attr
;
724 struct list_head head
;
726 struct drm_mode_object base
;
731 * @mutex: Lock for general connector state, but currently only protects
732 * @registered. Most of the connector state is still protected by
733 * &drm_mode_config.mutex.
738 * @index: Compacted connector index, which matches the position inside
739 * the mode_config.list for drivers not supporting hot-add/removing. Can
740 * be used as an array index. It is invariant over the lifetime of the
746 int connector_type_id
;
747 bool interlace_allowed
;
748 bool doublescan_allowed
;
752 * @ycbcr_420_allowed : This bool indicates if this connector is
753 * capable of handling YCBCR 420 output. While parsing the EDID
754 * blocks, its very helpful to know, if the source is capable of
755 * handling YCBCR 420 outputs.
757 bool ycbcr_420_allowed
;
760 * @registered: Is this connector exposed (registered) with userspace?
761 * Protected by @mutex.
767 * Modes available on this connector (from fill_modes() + user).
768 * Protected by &drm_mode_config.mutex.
770 struct list_head modes
;
774 * One of the drm_connector_status enums (connected, not, or unknown).
775 * Protected by &drm_mode_config.mutex.
777 enum drm_connector_status status
;
781 * These are modes added by probing with DDC or the BIOS, before
782 * filtering is applied. Used by the probe helpers. Protected by
783 * &drm_mode_config.mutex.
785 struct list_head probed_modes
;
788 * @display_info: Display information is filled from EDID information
789 * when a display is detected. For non hot-pluggable displays such as
790 * flat panels in embedded systems, the driver should initialize the
791 * &drm_display_info.width_mm and &drm_display_info.height_mm fields
792 * with the physical size of the display.
794 * Protected by &drm_mode_config.mutex.
796 struct drm_display_info display_info
;
797 const struct drm_connector_funcs
*funcs
;
799 struct drm_property_blob
*edid_blob_ptr
;
800 struct drm_object_properties properties
;
802 struct drm_property
*scaling_mode_property
;
807 * DRM blob property data for the DP MST path property.
809 struct drm_property_blob
*path_blob_ptr
;
814 * DRM blob property data for the tile property (used mostly by DP MST).
815 * This is meant for screens which are driven through separate display
816 * pipelines represented by &drm_crtc, which might not be running with
817 * genlocked clocks. For tiled panels which are genlocked, like
818 * dual-link LVDS or dual-link DSI, the driver should try to not expose
819 * the tiling and virtualize both &drm_crtc and &drm_plane if needed.
821 struct drm_property_blob
*tile_blob_ptr
;
823 /* should we poll this connector for connects and disconnects */
824 /* hot plug detectable */
825 #define DRM_CONNECTOR_POLL_HPD (1 << 0)
826 /* poll for connections */
827 #define DRM_CONNECTOR_POLL_CONNECT (1 << 1)
828 /* can cleanly poll for disconnections without flickering the screen */
829 /* DACs should rarely do this without a lot of testing */
830 #define DRM_CONNECTOR_POLL_DISCONNECT (1 << 2)
835 * Connector polling mode, a combination of
837 * DRM_CONNECTOR_POLL_HPD
838 * The connector generates hotplug events and doesn't need to be
839 * periodically polled. The CONNECT and DISCONNECT flags must not
840 * be set together with the HPD flag.
842 * DRM_CONNECTOR_POLL_CONNECT
843 * Periodically poll the connector for connection.
845 * DRM_CONNECTOR_POLL_DISCONNECT
846 * Periodically poll the connector for disconnection.
848 * Set to 0 for connectors that don't support connection status
853 /* requested DPMS state */
856 const struct drm_connector_helper_funcs
*helper_private
;
858 /* forced on connector */
859 struct drm_cmdline_mode cmdline_mode
;
860 enum drm_connector_force force
;
863 #define DRM_CONNECTOR_MAX_ENCODER 3
864 uint32_t encoder_ids
[DRM_CONNECTOR_MAX_ENCODER
];
865 struct drm_encoder
*encoder
; /* currently active encoder */
867 #define MAX_ELD_BYTES 128
869 uint8_t eld
[MAX_ELD_BYTES
];
870 bool latency_present
[2];
871 int video_latency
[2]; /* [0]: progressive, [1]: interlaced */
872 int audio_latency
[2];
873 int null_edid_counter
; /* needed to workaround some HW bugs where we get all 0s */
874 unsigned bad_edid_counter
;
876 /* Flag for raw EDID header corruption - used in Displayport
877 * compliance testing - * Displayport Link CTS Core 1.2 rev1.1 4.2.2.6
881 struct dentry
*debugfs_entry
;
886 * Current atomic state for this connector.
888 * This is protected by @drm_mode_config.connection_mutex. Note that
889 * nonblocking atomic commits access the current connector state without
890 * taking locks. Either by going through the &struct drm_atomic_state
891 * pointers, see for_each_connector_in_state(),
892 * for_each_oldnew_connector_in_state(),
893 * for_each_old_connector_in_state() and
894 * for_each_new_connector_in_state(). Or through careful ordering of
895 * atomic commit operations as implemented in the atomic helpers, see
896 * &struct drm_crtc_commit.
898 struct drm_connector_state
*state
;
902 struct drm_tile_group
*tile_group
;
903 bool tile_is_single_monitor
;
905 uint8_t num_h_tile
, num_v_tile
;
906 uint8_t tile_h_loc
, tile_v_loc
;
907 uint16_t tile_h_size
, tile_v_size
;
910 #define obj_to_connector(x) container_of(x, struct drm_connector, base)
912 int drm_connector_init(struct drm_device
*dev
,
913 struct drm_connector
*connector
,
914 const struct drm_connector_funcs
*funcs
,
916 int drm_connector_register(struct drm_connector
*connector
);
917 void drm_connector_unregister(struct drm_connector
*connector
);
918 int drm_mode_connector_attach_encoder(struct drm_connector
*connector
,
919 struct drm_encoder
*encoder
);
921 void drm_connector_cleanup(struct drm_connector
*connector
);
922 static inline unsigned drm_connector_index(struct drm_connector
*connector
)
924 return connector
->index
;
928 * drm_connector_lookup - lookup connector object
930 * @id: connector object id
932 * This function looks up the connector object specified by id
933 * add takes a reference to it.
935 static inline struct drm_connector
*drm_connector_lookup(struct drm_device
*dev
,
938 struct drm_mode_object
*mo
;
939 mo
= drm_mode_object_find(dev
, id
, DRM_MODE_OBJECT_CONNECTOR
);
940 return mo
? obj_to_connector(mo
) : NULL
;
944 * drm_connector_get - acquire a connector reference
945 * @connector: DRM connector
947 * This function increments the connector's refcount.
949 static inline void drm_connector_get(struct drm_connector
*connector
)
951 drm_mode_object_get(&connector
->base
);
955 * drm_connector_put - release a connector reference
956 * @connector: DRM connector
958 * This function decrements the connector's reference count and frees the
959 * object if the reference count drops to zero.
961 static inline void drm_connector_put(struct drm_connector
*connector
)
963 drm_mode_object_put(&connector
->base
);
967 * drm_connector_reference - acquire a connector reference
968 * @connector: DRM connector
970 * This is a compatibility alias for drm_connector_get() and should not be
973 static inline void drm_connector_reference(struct drm_connector
*connector
)
975 drm_connector_get(connector
);
979 * drm_connector_unreference - release a connector reference
980 * @connector: DRM connector
982 * This is a compatibility alias for drm_connector_put() and should not be
985 static inline void drm_connector_unreference(struct drm_connector
*connector
)
987 drm_connector_put(connector
);
990 const char *drm_get_connector_status_name(enum drm_connector_status status
);
991 const char *drm_get_subpixel_order_name(enum subpixel_order order
);
992 const char *drm_get_dpms_name(int val
);
993 const char *drm_get_dvi_i_subconnector_name(int val
);
994 const char *drm_get_dvi_i_select_name(int val
);
995 const char *drm_get_tv_subconnector_name(int val
);
996 const char *drm_get_tv_select_name(int val
);
998 int drm_mode_create_dvi_i_properties(struct drm_device
*dev
);
999 int drm_mode_create_tv_properties(struct drm_device
*dev
,
1000 unsigned int num_modes
,
1001 const char * const modes
[]);
1002 int drm_mode_create_scaling_mode_property(struct drm_device
*dev
);
1003 int drm_connector_attach_scaling_mode_property(struct drm_connector
*connector
,
1004 u32 scaling_mode_mask
);
1005 int drm_mode_create_aspect_ratio_property(struct drm_device
*dev
);
1006 int drm_mode_create_suggested_offset_properties(struct drm_device
*dev
);
1008 int drm_mode_connector_set_path_property(struct drm_connector
*connector
,
1010 int drm_mode_connector_set_tile_property(struct drm_connector
*connector
);
1011 int drm_mode_connector_update_edid_property(struct drm_connector
*connector
,
1012 const struct edid
*edid
);
1013 void drm_mode_connector_set_link_status_property(struct drm_connector
*connector
,
1014 uint64_t link_status
);
1017 * struct drm_tile_group - Tile group metadata
1018 * @refcount: reference count
1020 * @id: tile group id exposed to userspace
1021 * @group_data: Sink-private data identifying this group
1023 * @group_data corresponds to displayid vend/prod/serial for external screens
1026 struct drm_tile_group
{
1027 struct kref refcount
;
1028 struct drm_device
*dev
;
1033 struct drm_tile_group
*drm_mode_create_tile_group(struct drm_device
*dev
,
1035 struct drm_tile_group
*drm_mode_get_tile_group(struct drm_device
*dev
,
1037 void drm_mode_put_tile_group(struct drm_device
*dev
,
1038 struct drm_tile_group
*tg
);
1041 * struct drm_connector_list_iter - connector_list iterator
1043 * This iterator tracks state needed to be able to walk the connector_list
1044 * within struct drm_mode_config. Only use together with
1045 * drm_connector_list_iter_begin(), drm_connector_list_iter_end() and
1046 * drm_connector_list_iter_next() respectively the convenience macro
1047 * drm_for_each_connector_iter().
1049 struct drm_connector_list_iter
{
1051 struct drm_device
*dev
;
1052 struct drm_connector
*conn
;
1055 void drm_connector_list_iter_begin(struct drm_device
*dev
,
1056 struct drm_connector_list_iter
*iter
);
1057 struct drm_connector
*
1058 drm_connector_list_iter_next(struct drm_connector_list_iter
*iter
);
1059 void drm_connector_list_iter_end(struct drm_connector_list_iter
*iter
);
1062 * drm_for_each_connector_iter - connector_list iterator macro
1063 * @connector: &struct drm_connector pointer used as cursor
1064 * @iter: &struct drm_connector_list_iter
1066 * Note that @connector is only valid within the list body, if you want to use
1067 * @connector after calling drm_connector_list_iter_end() then you need to grab
1068 * your own reference first using drm_connector_get().
1070 #define drm_for_each_connector_iter(connector, iter) \
1071 while ((connector = drm_connector_list_iter_next(iter)))