/* * Copyright (c) 2016 Intel Corporation * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that copyright * notice and this permission notice appear in supporting documentation, and * that the name of the copyright holders not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. The copyright holders make no representations * about the suitability of this software for any purpose. It is provided "as * is" without express or implied warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE * OF THIS SOFTWARE. */ #ifndef __DRM_CONNECTOR_H__ #define __DRM_CONNECTOR_H__ #include <linux/list.h> #include <linux/llist.h> #include <linux/ctype.h> #include <linux/hdmi.h> #include <linux/notifier.h> #include <drm/drm_mode_object.h> #include <drm/drm_util.h> #include <drm/drm_property.h> #include <uapi/drm/drm_mode.h> struct drm_connector_helper_funcs; struct drm_modeset_acquire_ctx; struct drm_device; struct drm_crtc; struct drm_display_mode; struct drm_encoder; struct drm_panel; struct drm_property; struct drm_property_blob; struct drm_printer; struct drm_privacy_screen; struct edid; struct i2c_adapter; enum drm_connector_force { … }; /** * enum drm_connector_status - status for a &drm_connector * * This enum is used to track the connector status. There are no separate * #defines for the uapi! */ enum drm_connector_status { … }; /** * enum drm_connector_registration_state - userspace registration status for * a &drm_connector * * This enum is used to track the status of initializing a connector and * registering it with userspace, so that DRM can prevent bogus modesets on * connectors that no longer exist. */ enum drm_connector_registration_state { … }; enum subpixel_order { … }; /** * enum drm_connector_tv_mode - Analog TV output mode * * This enum is used to indicate the TV output mode used on an analog TV * connector. * * WARNING: The values of this enum is uABI since they're exposed in the * "TV mode" connector property. */ enum drm_connector_tv_mode { … }; /** * struct drm_scrambling: sink's scrambling support. */ struct drm_scrambling { … }; /* * struct drm_scdc - Information about scdc capabilities of a HDMI 2.0 sink * * Provides SCDC register support and capabilities related information on a * HDMI 2.0 sink. In case of a HDMI 1.4 sink, all parameter must be 0. */ struct drm_scdc { … }; /** * struct drm_hdmi_dsc_cap - DSC capabilities of HDMI sink * * Describes the DSC support provided by HDMI 2.1 sink. * The information is fetched fom additional HFVSDB blocks defined * for HDMI 2.1. */ struct drm_hdmi_dsc_cap { … }; /** * struct drm_hdmi_info - runtime information about the connected HDMI sink * * Describes if a given display supports advanced HDMI 2.0 features. * This information is available in CEA-861-F extension blocks (like HF-VSDB). */ struct drm_hdmi_info { … }; /** * enum drm_link_status - connector's link_status property value * * This enum is used as the connector's link status property value. * It is set to the values defined in uapi. * * @DRM_LINK_STATUS_GOOD: DP Link is Good as a result of successful * link training * @DRM_LINK_STATUS_BAD: DP Link is BAD as a result of link training * failure */ enum drm_link_status { … }; /** * enum drm_panel_orientation - panel_orientation info for &drm_display_info * * This enum is used to track the (LCD) panel orientation. There are no * separate #defines for the uapi! * * @DRM_MODE_PANEL_ORIENTATION_UNKNOWN: The drm driver has not provided any * panel orientation information (normal * for non panels) in this case the "panel * orientation" connector prop will not be * attached. * @DRM_MODE_PANEL_ORIENTATION_NORMAL: The top side of the panel matches the * top side of the device's casing. * @DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP: The top side of the panel matches the * bottom side of the device's casing, iow * the panel is mounted upside-down. * @DRM_MODE_PANEL_ORIENTATION_LEFT_UP: The left side of the panel matches the * top side of the device's casing. * @DRM_MODE_PANEL_ORIENTATION_RIGHT_UP: The right side of the panel matches the * top side of the device's casing. */ enum drm_panel_orientation { … }; /** * enum drm_hdmi_broadcast_rgb - Broadcast RGB Selection for an HDMI @drm_connector */ enum drm_hdmi_broadcast_rgb { … }; const char * drm_hdmi_connector_get_broadcast_rgb_name(enum drm_hdmi_broadcast_rgb broadcast_rgb); const char * drm_hdmi_connector_get_output_format_name(enum hdmi_colorspace fmt); /** * struct drm_monitor_range_info - Panel's Monitor range in EDID for * &drm_display_info * * This struct is used to store a frequency range supported by panel * as parsed from EDID's detailed monitor range descriptor block. * * @min_vfreq: This is the min supported refresh rate in Hz from * EDID's detailed monitor range. * @max_vfreq: This is the max supported refresh rate in Hz from * EDID's detailed monitor range */ struct drm_monitor_range_info { … }; /** * struct drm_luminance_range_info - Panel's luminance range for * &drm_display_info. Calculated using data in EDID * * This struct is used to store a luminance range supported by panel * as calculated using data from EDID's static hdr metadata. * * @min_luminance: This is the min supported luminance value * * @max_luminance: This is the max supported luminance value */ struct drm_luminance_range_info { … }; /** * enum drm_privacy_screen_status - privacy screen status * * This enum is used to track and control the state of the integrated privacy * screen present on some display panels, via the "privacy-screen sw-state" * and "privacy-screen hw-state" properties. Note the _LOCKED enum values * are only valid for the "privacy-screen hw-state" property. * * @PRIVACY_SCREEN_DISABLED: * The privacy-screen on the panel is disabled * @PRIVACY_SCREEN_ENABLED: * The privacy-screen on the panel is enabled * @PRIVACY_SCREEN_DISABLED_LOCKED: * The privacy-screen on the panel is disabled and locked (cannot be changed) * @PRIVACY_SCREEN_ENABLED_LOCKED: * The privacy-screen on the panel is enabled and locked (cannot be changed) */ enum drm_privacy_screen_status { … }; /** * enum drm_colorspace - color space * * This enum is a consolidated colorimetry list supported by HDMI and * DP protocol standard. The respective connectors will register * a property with the subset of this list (supported by that * respective protocol). Userspace will set the colorspace through * a colorspace property which will be created and exposed to * userspace. * * DP definitions come from the DP v2.0 spec * HDMI definitions come from the CTA-861-H spec * * A note on YCC and RGB variants: * * Since userspace is not aware of the encoding on the wire * (RGB or YCbCr), drivers are free to pick the appropriate * variant, regardless of what userspace selects. E.g., if * BT2020_RGB is selected by userspace a driver will pick * BT2020_YCC if the encoding on the wire is YUV444 or YUV420. * * @DRM_MODE_COLORIMETRY_DEFAULT: * Driver specific behavior. * @DRM_MODE_COLORIMETRY_NO_DATA: * Driver specific behavior. * @DRM_MODE_COLORIMETRY_SMPTE_170M_YCC: * (HDMI) * SMPTE ST 170M colorimetry format * @DRM_MODE_COLORIMETRY_BT709_YCC: * (HDMI, DP) * ITU-R BT.709 colorimetry format * @DRM_MODE_COLORIMETRY_XVYCC_601: * (HDMI, DP) * xvYCC601 colorimetry format * @DRM_MODE_COLORIMETRY_XVYCC_709: * (HDMI, DP) * xvYCC709 colorimetry format * @DRM_MODE_COLORIMETRY_SYCC_601: * (HDMI, DP) * sYCC601 colorimetry format * @DRM_MODE_COLORIMETRY_OPYCC_601: * (HDMI, DP) * opYCC601 colorimetry format * @DRM_MODE_COLORIMETRY_OPRGB: * (HDMI, DP) * opRGB colorimetry format * @DRM_MODE_COLORIMETRY_BT2020_CYCC: * (HDMI, DP) * ITU-R BT.2020 Y'c C'bc C'rc (constant luminance) colorimetry format * @DRM_MODE_COLORIMETRY_BT2020_RGB: * (HDMI, DP) * ITU-R BT.2020 R' G' B' colorimetry format * @DRM_MODE_COLORIMETRY_BT2020_YCC: * (HDMI, DP) * ITU-R BT.2020 Y' C'b C'r colorimetry format * @DRM_MODE_COLORIMETRY_DCI_P3_RGB_D65: * (HDMI) * SMPTE ST 2113 P3D65 colorimetry format * @DRM_MODE_COLORIMETRY_DCI_P3_RGB_THEATER: * (HDMI) * SMPTE ST 2113 P3DCI colorimetry format * @DRM_MODE_COLORIMETRY_RGB_WIDE_FIXED: * (DP) * RGB wide gamut fixed point colorimetry format * @DRM_MODE_COLORIMETRY_RGB_WIDE_FLOAT: * (DP) * RGB wide gamut floating point * (scRGB (IEC 61966-2-2)) colorimetry format * @DRM_MODE_COLORIMETRY_BT601_YCC: * (DP) * ITU-R BT.601 colorimetry format * The DP spec does not say whether this is the 525 or the 625 * line version. * @DRM_MODE_COLORIMETRY_COUNT: * Not a valid value; merely used four counting */ enum drm_colorspace { … }; /** * enum drm_bus_flags - bus_flags info for &drm_display_info * * This enum defines signal polarities and clock edge information for signals on * a bus as bitmask flags. * * The clock edge information is conveyed by two sets of symbols, * DRM_BUS_FLAGS_*_DRIVE_\* and DRM_BUS_FLAGS_*_SAMPLE_\*. When this enum is * used to describe a bus from the point of view of the transmitter, the * \*_DRIVE_\* flags should be used. When used from the point of view of the * receiver, the \*_SAMPLE_\* flags should be used. The \*_DRIVE_\* and * \*_SAMPLE_\* flags alias each other, with the \*_SAMPLE_POSEDGE and * \*_SAMPLE_NEGEDGE flags being equal to \*_DRIVE_NEGEDGE and \*_DRIVE_POSEDGE * respectively. This simplifies code as signals are usually sampled on the * opposite edge of the driving edge. Transmitters and receivers may however * need to take other signal timings into account to convert between driving * and sample edges. */ enum drm_bus_flags { … }; /** * struct drm_display_info - runtime data about the connected sink * * Describes a given display (e.g. CRT or flat panel) and its limitations. For * fixed display sinks like built-in panels there's not much difference between * this and &struct drm_connector. But for sinks with a real cable this * structure is meant to describe all the things at the other end of the cable. * * For sinks which provide an EDID this can be filled out by calling * drm_add_edid_modes(). */ struct drm_display_info { … }; int drm_display_info_set_bus_formats(struct drm_display_info *info, const u32 *formats, unsigned int num_formats); /** * struct drm_connector_tv_margins - TV connector related margins * * Describes the margins in pixels to put around the image on TV * connectors to deal with overscan. */ struct drm_connector_tv_margins { … }; /** * struct drm_tv_connector_state - TV connector related states * @select_subconnector: selected subconnector * @subconnector: detected subconnector * @margins: TV margins * @legacy_mode: Legacy TV mode, driver specific value * @mode: TV mode * @brightness: brightness in percent * @contrast: contrast in percent * @flicker_reduction: flicker reduction in percent * @overscan: overscan in percent * @saturation: saturation in percent * @hue: hue in percent */ struct drm_tv_connector_state { … }; /** * struct drm_connector_hdmi_infoframe - HDMI Infoframe container */ struct drm_connector_hdmi_infoframe { … }; /* * struct drm_connector_hdmi_state - HDMI state container */ struct drm_connector_hdmi_state { … }; /** * struct drm_connector_state - mutable connector state */ struct drm_connector_state { … }; /** * struct drm_connector_hdmi_funcs - drm_hdmi_connector control functions */ struct drm_connector_hdmi_funcs { … }; /** * struct drm_connector_funcs - control connectors on a given device * * Each CRTC may have one or more connectors attached to it. The functions * below allow the core DRM code to control connectors, enumerate available modes, * etc. */ struct drm_connector_funcs { … }; /** * struct drm_cmdline_mode - DRM Mode passed through the kernel command-line * * Each connector can have an initial mode with additional options * passed through the kernel command line. This structure allows to * express those parameters and will be filled by the command-line * parser. */ struct drm_cmdline_mode { … }; /* * struct drm_connector_hdmi - DRM Connector HDMI-related structure */ struct drm_connector_hdmi { … }; /** * struct drm_connector - central DRM connector control structure * * Each connector may be connected to one or more CRTCs, or may be clonable by * another connector if they can share a CRTC. Each connector also has a specific * position in the broader display (referred to as a 'screen' though it could * span multiple monitors). */ struct drm_connector { … }; #define obj_to_connector(x) … int drm_connector_init(struct drm_device *dev, struct drm_connector *connector, const struct drm_connector_funcs *funcs, int connector_type); int drm_connector_init_with_ddc(struct drm_device *dev, struct drm_connector *connector, const struct drm_connector_funcs *funcs, int connector_type, struct i2c_adapter *ddc); int drmm_connector_init(struct drm_device *dev, struct drm_connector *connector, const struct drm_connector_funcs *funcs, int connector_type, struct i2c_adapter *ddc); int drmm_connector_hdmi_init(struct drm_device *dev, struct drm_connector *connector, const char *vendor, const char *product, const struct drm_connector_funcs *funcs, const struct drm_connector_hdmi_funcs *hdmi_funcs, int connector_type, struct i2c_adapter *ddc, unsigned long supported_formats, unsigned int max_bpc); void drm_connector_attach_edid_property(struct drm_connector *connector); int drm_connector_register(struct drm_connector *connector); void drm_connector_unregister(struct drm_connector *connector); int drm_connector_attach_encoder(struct drm_connector *connector, struct drm_encoder *encoder); void drm_connector_cleanup(struct drm_connector *connector); static inline unsigned int drm_connector_index(const struct drm_connector *connector) { … } static inline u32 drm_connector_mask(const struct drm_connector *connector) { … } /** * drm_connector_lookup - lookup connector object * @dev: DRM device * @file_priv: drm file to check for lease against. * @id: connector object id * * This function looks up the connector object specified by id * add takes a reference to it. */ static inline struct drm_connector *drm_connector_lookup(struct drm_device *dev, struct drm_file *file_priv, uint32_t id) { … } /** * drm_connector_get - acquire a connector reference * @connector: DRM connector * * This function increments the connector's refcount. */ static inline void drm_connector_get(struct drm_connector *connector) { … } /** * drm_connector_put - release a connector reference * @connector: DRM connector * * This function decrements the connector's reference count and frees the * object if the reference count drops to zero. */ static inline void drm_connector_put(struct drm_connector *connector) { … } /** * drm_connector_is_unregistered - has the connector been unregistered from * userspace? * @connector: DRM connector * * Checks whether or not @connector has been unregistered from userspace. * * Returns: * True if the connector was unregistered, false if the connector is * registered or has not yet been registered with userspace. */ static inline bool drm_connector_is_unregistered(struct drm_connector *connector) { … } void drm_connector_oob_hotplug_event(struct fwnode_handle *connector_fwnode, enum drm_connector_status status); const char *drm_get_connector_type_name(unsigned int connector_type); const char *drm_get_connector_status_name(enum drm_connector_status status); const char *drm_get_subpixel_order_name(enum subpixel_order order); const char *drm_get_dpms_name(int val); const char *drm_get_dvi_i_subconnector_name(int val); const char *drm_get_dvi_i_select_name(int val); const char *drm_get_tv_mode_name(int val); const char *drm_get_tv_subconnector_name(int val); const char *drm_get_tv_select_name(int val); const char *drm_get_dp_subconnector_name(int val); const char *drm_get_content_protection_name(int val); const char *drm_get_hdcp_content_type_name(int val); int drm_get_tv_mode_from_name(const char *name, size_t len); int drm_mode_create_dvi_i_properties(struct drm_device *dev); void drm_connector_attach_dp_subconnector_property(struct drm_connector *connector); int drm_mode_create_tv_margin_properties(struct drm_device *dev); int drm_mode_create_tv_properties_legacy(struct drm_device *dev, unsigned int num_modes, const char * const modes[]); int drm_mode_create_tv_properties(struct drm_device *dev, unsigned int supported_tv_modes); void drm_connector_attach_tv_margin_properties(struct drm_connector *conn); int drm_mode_create_scaling_mode_property(struct drm_device *dev); int drm_connector_attach_content_type_property(struct drm_connector *dev); int drm_connector_attach_scaling_mode_property(struct drm_connector *connector, u32 scaling_mode_mask); int drm_connector_attach_vrr_capable_property( struct drm_connector *connector); int drm_connector_attach_broadcast_rgb_property(struct drm_connector *connector); int drm_connector_attach_colorspace_property(struct drm_connector *connector); int drm_connector_attach_hdr_output_metadata_property(struct drm_connector *connector); bool drm_connector_atomic_hdr_metadata_equal(struct drm_connector_state *old_state, struct drm_connector_state *new_state); int drm_mode_create_aspect_ratio_property(struct drm_device *dev); int drm_mode_create_hdmi_colorspace_property(struct drm_connector *connector, u32 supported_colorspaces); int drm_mode_create_dp_colorspace_property(struct drm_connector *connector, u32 supported_colorspaces); int drm_mode_create_content_type_property(struct drm_device *dev); int drm_mode_create_suggested_offset_properties(struct drm_device *dev); int drm_connector_set_path_property(struct drm_connector *connector, const char *path); int drm_connector_set_tile_property(struct drm_connector *connector); int drm_connector_update_edid_property(struct drm_connector *connector, const struct edid *edid); void drm_connector_set_link_status_property(struct drm_connector *connector, uint64_t link_status); void drm_connector_set_vrr_capable_property( struct drm_connector *connector, bool capable); int drm_connector_set_panel_orientation( struct drm_connector *connector, enum drm_panel_orientation panel_orientation); int drm_connector_set_panel_orientation_with_quirk( struct drm_connector *connector, enum drm_panel_orientation panel_orientation, int width, int height); int drm_connector_set_orientation_from_panel( struct drm_connector *connector, struct drm_panel *panel); int drm_connector_attach_max_bpc_property(struct drm_connector *connector, int min, int max); void drm_connector_create_privacy_screen_properties(struct drm_connector *conn); void drm_connector_attach_privacy_screen_properties(struct drm_connector *conn); void drm_connector_attach_privacy_screen_provider( struct drm_connector *connector, struct drm_privacy_screen *priv); void drm_connector_update_privacy_screen(const struct drm_connector_state *connector_state); /** * struct drm_tile_group - Tile group metadata * @refcount: reference count * @dev: DRM device * @id: tile group id exposed to userspace * @group_data: Sink-private data identifying this group * * @group_data corresponds to displayid vend/prod/serial for external screens * with an EDID. */ struct drm_tile_group { … }; struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev, const char topology[8]); struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev, const char topology[8]); void drm_mode_put_tile_group(struct drm_device *dev, struct drm_tile_group *tg); /** * struct drm_connector_list_iter - connector_list iterator * * This iterator tracks state needed to be able to walk the connector_list * within struct drm_mode_config. Only use together with * drm_connector_list_iter_begin(), drm_connector_list_iter_end() and * drm_connector_list_iter_next() respectively the convenience macro * drm_for_each_connector_iter(). * * Note that the return value of drm_connector_list_iter_next() is only valid * up to the next drm_connector_list_iter_next() or * drm_connector_list_iter_end() call. If you want to use the connector later, * then you need to grab your own reference first using drm_connector_get(). */ struct drm_connector_list_iter { … }; void drm_connector_list_iter_begin(struct drm_device *dev, struct drm_connector_list_iter *iter); struct drm_connector * drm_connector_list_iter_next(struct drm_connector_list_iter *iter); void drm_connector_list_iter_end(struct drm_connector_list_iter *iter); bool drm_connector_has_possible_encoder(struct drm_connector *connector, struct drm_encoder *encoder); const char *drm_get_colorspace_name(enum drm_colorspace colorspace); /** * drm_for_each_connector_iter - connector_list iterator macro * @connector: &struct drm_connector pointer used as cursor * @iter: &struct drm_connector_list_iter * * Note that @connector is only valid within the list body, if you want to use * @connector after calling drm_connector_list_iter_end() then you need to grab * your own reference first using drm_connector_get(). */ #define drm_for_each_connector_iter(connector, iter) … /** * drm_connector_for_each_possible_encoder - iterate connector's possible encoders * @connector: &struct drm_connector pointer * @encoder: &struct drm_encoder pointer used as cursor */ #define drm_connector_for_each_possible_encoder(connector, encoder) … #endif