Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/probe-helper: add drm_connector_helper_get_modes()

Add a helper function to be used as the "default" .get_modes()
hook. This also works as an example of what the driver .get_modes()
hooks are supposed to do regarding the new drm_edid_read*() and
drm_edid_connector_update() calls.

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/d985449ed4b95971490ab7c09d2d59b58a892769.1656494768.git.jani.nikula@intel.com

+35
+34
drivers/gpu/drm/drm_probe_helper.c
··· 1049 1049 return count; 1050 1050 } 1051 1051 EXPORT_SYMBOL(drm_connector_helper_get_modes_from_ddc); 1052 + 1053 + /** 1054 + * drm_connector_helper_get_modes - Read EDID and update connector. 1055 + * @connector: The connector 1056 + * 1057 + * Read the EDID using drm_edid_read() (which requires that connector->ddc is 1058 + * set), and update the connector using the EDID. 1059 + * 1060 + * This can be used as the "default" connector helper .get_modes() hook if the 1061 + * driver does not need any special processing. This is sets the example what 1062 + * custom .get_modes() hooks should do regarding EDID read and connector update. 1063 + * 1064 + * Returns: Number of modes. 1065 + */ 1066 + int drm_connector_helper_get_modes(struct drm_connector *connector) 1067 + { 1068 + const struct drm_edid *drm_edid; 1069 + int count; 1070 + 1071 + drm_edid = drm_edid_read(connector); 1072 + 1073 + /* 1074 + * Unconditionally update the connector. If the EDID was read 1075 + * successfully, fill in the connector information derived from the 1076 + * EDID. Otherwise, if the EDID is NULL, clear the connector 1077 + * information. 1078 + */ 1079 + count = drm_edid_connector_update(connector, drm_edid); 1080 + 1081 + drm_edid_free(drm_edid); 1082 + 1083 + return count; 1084 + } 1085 + EXPORT_SYMBOL(drm_connector_helper_get_modes);
+1
include/drm/drm_probe_helper.h
··· 27 27 bool drm_kms_helper_is_poll_worker(void); 28 28 29 29 int drm_connector_helper_get_modes_from_ddc(struct drm_connector *connector); 30 + int drm_connector_helper_get_modes(struct drm_connector *connector); 30 31 31 32 #endif