]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/mgag200: Implement connector's get_modes with helper
authorThomas Zimmermann <tzimmermann@suse.de>
Mon, 16 May 2022 13:43:39 +0000 (15:43 +0200)
committerThomas Zimmermann <tzimmermann@suse.de>
Tue, 17 May 2022 18:23:38 +0000 (20:23 +0200)
Provide drm_connector_helper_get_modes_from_ddc() to implement the
connector's get_modes callback. The new helper updates the connector
from DDC-provided EDID data.

v2:
* clear property if EDID is NULL in helper

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
Tested-by: Jocelyn Falempe <jfalempe@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220516134343.6085-4-tzimmermann@suse.de
drivers/gpu/drm/drm_probe_helper.c
drivers/gpu/drm/mgag200/mgag200_mode.c
include/drm/drm_probe_helper.h

index 682359512996a11f588a93a3badd23cda2660a18..d77f17867195293c9ea3027f255d0c3f3ab4e955 100644 (file)
@@ -964,3 +964,39 @@ bool drm_helper_hpd_irq_event(struct drm_device *dev)
        return changed;
 }
 EXPORT_SYMBOL(drm_helper_hpd_irq_event);
+
+/**
+ * drm_connector_helper_get_modes_from_ddc - Updates the connector's EDID
+ *                                           property from the connector's
+ *                                           DDC channel
+ * @connector: The connector
+ *
+ * Returns:
+ * The number of detected display modes.
+ *
+ * Uses a connector's DDC channel to retrieve EDID data and update the
+ * connector's EDID property and display modes. Drivers can use this
+ * function to implement struct &drm_connector_helper_funcs.get_modes
+ * for connectors with a DDC channel.
+ */
+int drm_connector_helper_get_modes_from_ddc(struct drm_connector *connector)
+{
+       struct edid *edid;
+       int count = 0;
+
+       if (!connector->ddc)
+               return 0;
+
+       edid = drm_get_edid(connector, connector->ddc);
+
+       // clears property if EDID is NULL
+       drm_connector_update_edid_property(connector, edid);
+
+       if (edid) {
+               count = drm_add_edid_modes(connector, edid);
+               kfree(edid);
+       }
+
+       return count;
+}
+EXPORT_SYMBOL(drm_connector_helper_get_modes_from_ddc);
index b227891d01ec711e475ffd1046c77a7eb7f62056..4c0680dd1a78242736b379c6c5caf47ff8090151 100644 (file)
@@ -689,26 +689,17 @@ static void mgag200_disable_display(struct mga_device *mdev)
  * Connector
  */
 
-static int mga_vga_get_modes(struct drm_connector *connector)
+static int mgag200_vga_connector_helper_get_modes(struct drm_connector *connector)
 {
        struct mga_device *mdev = to_mga_device(connector->dev);
-       struct mga_connector *mga_connector = to_mga_connector(connector);
-       struct edid *edid;
-       int ret = 0;
+       int ret;
 
        /*
         * Protect access to I/O registers from concurrent modesetting
         * by acquiring the I/O-register lock.
         */
        mutex_lock(&mdev->rmmio_lock);
-
-       edid = drm_get_edid(connector, &mga_connector->i2c->adapter);
-       if (edid) {
-               drm_connector_update_edid_property(connector, edid);
-               ret = drm_add_edid_modes(connector, edid);
-               kfree(edid);
-       }
-
+       ret = drm_connector_helper_get_modes_from_ddc(connector);
        mutex_unlock(&mdev->rmmio_lock);
 
        return ret;
@@ -828,7 +819,7 @@ static void mga_connector_destroy(struct drm_connector *connector)
 }
 
 static const struct drm_connector_helper_funcs mga_vga_connector_helper_funcs = {
-       .get_modes  = mga_vga_get_modes,
+       .get_modes  = mgag200_vga_connector_helper_get_modes,
        .mode_valid = mga_vga_mode_valid,
 };
 
index 48300aa6ca714e75419ed9e8eff12f0fbe3f373e..c80cab7a53b771010d71e7944fd2141abe6c4096 100644 (file)
@@ -26,4 +26,6 @@ void drm_kms_helper_poll_disable(struct drm_device *dev);
 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);
+
 #endif