Message ID | 977ae3f897f41ce69e091e38706ca841900c31b5.1654674560.git.jani.nikula@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/edid: expand on struct drm_edid usage | expand |
On Wed, Jun 08, 2022 at 10:50:38AM +0300, Jani Nikula wrote: > 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> > --- > drivers/gpu/drm/drm_probe_helper.c | 34 ++++++++++++++++++++++++++++++ > include/drm/drm_probe_helper.h | 1 + > 2 files changed, 35 insertions(+) > > diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c > index a8d26b29bfa0..e6b8f2923aa7 100644 > --- a/drivers/gpu/drm/drm_probe_helper.c > +++ b/drivers/gpu/drm/drm_probe_helper.c > @@ -1049,3 +1049,37 @@ int drm_connector_helper_get_modes_from_ddc(struct drm_connector *connector) > return count; > } > EXPORT_SYMBOL(drm_connector_helper_get_modes_from_ddc); > + > +/** > + * drm_connector_helper_get_modes - Read EDID and update connector. > + * @connector: The connector > + * > + * Read the EDID using drm_edid_read() (which requires that connector->ddc is > + * set), and update the connector using the EDID. > + * > + * This can be used as the "default" connector helper .get_modes() hook if the > + * driver does not need any special processing. This is sets the example what > + * custom .get_modes() hooks should do regarding EDID read and connector update. > + * > + * Returns: Number of modes. > + */ > +int drm_connector_helper_get_modes(struct drm_connector *connector) > +{ > + const struct drm_edid *drm_edid; > + int count; > + > + drm_edid = drm_edid_read(connector); > + > + /* > + * Unconditionally update the connector. If the EDID was read > + * succesfully, fill in the connector information derived from the > + * EDID. Otherwise, if the EDID is NULL, clear the connector > + * information. > + */ > + count = drm_edid_connector_update(connector, drm_edid); > + > + drm_edid_free(drm_edid); > + > + return count; > +} > +EXPORT_SYMBOL(drm_connector_helper_get_modes); > diff --git a/include/drm/drm_probe_helper.h b/include/drm/drm_probe_helper.h > index c80cab7a53b7..8075e02aa865 100644 > --- a/include/drm/drm_probe_helper.h > +++ b/include/drm/drm_probe_helper.h > @@ -27,5 +27,6 @@ void drm_kms_helper_poll_enable(struct drm_device *dev); > bool drm_kms_helper_is_poll_worker(void); > > int drm_connector_helper_get_modes_from_ddc(struct drm_connector *connector); > +int drm_connector_helper_get_modes(struct drm_connector *connector); > > #endif > -- > 2.30.2
diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c index a8d26b29bfa0..e6b8f2923aa7 100644 --- a/drivers/gpu/drm/drm_probe_helper.c +++ b/drivers/gpu/drm/drm_probe_helper.c @@ -1049,3 +1049,37 @@ int drm_connector_helper_get_modes_from_ddc(struct drm_connector *connector) return count; } EXPORT_SYMBOL(drm_connector_helper_get_modes_from_ddc); + +/** + * drm_connector_helper_get_modes - Read EDID and update connector. + * @connector: The connector + * + * Read the EDID using drm_edid_read() (which requires that connector->ddc is + * set), and update the connector using the EDID. + * + * This can be used as the "default" connector helper .get_modes() hook if the + * driver does not need any special processing. This is sets the example what + * custom .get_modes() hooks should do regarding EDID read and connector update. + * + * Returns: Number of modes. + */ +int drm_connector_helper_get_modes(struct drm_connector *connector) +{ + const struct drm_edid *drm_edid; + int count; + + drm_edid = drm_edid_read(connector); + + /* + * Unconditionally update the connector. If the EDID was read + * succesfully, fill in the connector information derived from the + * EDID. Otherwise, if the EDID is NULL, clear the connector + * information. + */ + count = drm_edid_connector_update(connector, drm_edid); + + drm_edid_free(drm_edid); + + return count; +} +EXPORT_SYMBOL(drm_connector_helper_get_modes); diff --git a/include/drm/drm_probe_helper.h b/include/drm/drm_probe_helper.h index c80cab7a53b7..8075e02aa865 100644 --- a/include/drm/drm_probe_helper.h +++ b/include/drm/drm_probe_helper.h @@ -27,5 +27,6 @@ void drm_kms_helper_poll_enable(struct drm_device *dev); bool drm_kms_helper_is_poll_worker(void); int drm_connector_helper_get_modes_from_ddc(struct drm_connector *connector); +int drm_connector_helper_get_modes(struct drm_connector *connector); #endif
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> --- drivers/gpu/drm/drm_probe_helper.c | 34 ++++++++++++++++++++++++++++++ include/drm/drm_probe_helper.h | 1 + 2 files changed, 35 insertions(+)