]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/tilcdc: Remove obsolete crtc_mode_valid() hack
authorJyri Sarha <jsarha@ti.com>
Fri, 2 Aug 2019 12:55:22 +0000 (15:55 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 29 Jul 2022 15:10:35 +0000 (17:10 +0200)
[ Upstream commit 57d8396504b3a93f284e51b866740a3e7419a3d9 ]

Earlier there were no mode_valid() helper for crtc and tilcdc had a
hack to over come this limitation. But now the mode_valid() helper is
there (has been since v4.13), so it is about time to get rid of that
hack.

Signed-off-by: Jyri Sarha <jsarha@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://patchwork.freedesktop.org/patch/msgid/
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/tilcdc/tilcdc_crtc.c
drivers/gpu/drm/tilcdc/tilcdc_drv.c
drivers/gpu/drm/tilcdc/tilcdc_drv.h
drivers/gpu/drm/tilcdc/tilcdc_external.c
drivers/gpu/drm/tilcdc/tilcdc_external.h
drivers/gpu/drm/tilcdc/tilcdc_panel.c
drivers/gpu/drm/tilcdc/tilcdc_tfp410.c

index 1067e702c22c70d5a1ee509adbe9036779a17f81..31a2d1ecce3e7f224dfe4cfc772c0dbfbd15bc5c 100644 (file)
@@ -657,9 +657,6 @@ static bool tilcdc_crtc_mode_fixup(struct drm_crtc *crtc,
 static int tilcdc_crtc_atomic_check(struct drm_crtc *crtc,
                                    struct drm_crtc_state *state)
 {
-       struct drm_display_mode *mode = &state->mode;
-       int ret;
-
        /* If we are not active we don't care */
        if (!state->active)
                return 0;
@@ -671,12 +668,6 @@ static int tilcdc_crtc_atomic_check(struct drm_crtc *crtc,
                return -EINVAL;
        }
 
-       ret = tilcdc_crtc_mode_valid(crtc, mode);
-       if (ret) {
-               dev_dbg(crtc->dev->dev, "Mode \"%s\" not valid", mode->name);
-               return -EINVAL;
-       }
-
        return 0;
 }
 
@@ -728,13 +719,6 @@ static const struct drm_crtc_funcs tilcdc_crtc_funcs = {
        .disable_vblank = tilcdc_crtc_disable_vblank,
 };
 
-static const struct drm_crtc_helper_funcs tilcdc_crtc_helper_funcs = {
-               .mode_fixup     = tilcdc_crtc_mode_fixup,
-               .atomic_check   = tilcdc_crtc_atomic_check,
-               .atomic_enable  = tilcdc_crtc_atomic_enable,
-               .atomic_disable = tilcdc_crtc_atomic_disable,
-};
-
 int tilcdc_crtc_max_width(struct drm_crtc *crtc)
 {
        struct drm_device *dev = crtc->dev;
@@ -749,7 +733,9 @@ int tilcdc_crtc_max_width(struct drm_crtc *crtc)
        return max_width;
 }
 
-int tilcdc_crtc_mode_valid(struct drm_crtc *crtc, struct drm_display_mode *mode)
+static enum drm_mode_status
+tilcdc_crtc_mode_valid(struct drm_crtc *crtc,
+                      const struct drm_display_mode *mode)
 {
        struct tilcdc_drm_private *priv = crtc->dev->dev_private;
        unsigned int bandwidth;
@@ -837,6 +823,14 @@ int tilcdc_crtc_mode_valid(struct drm_crtc *crtc, struct drm_display_mode *mode)
        return MODE_OK;
 }
 
+static const struct drm_crtc_helper_funcs tilcdc_crtc_helper_funcs = {
+       .mode_valid     = tilcdc_crtc_mode_valid,
+       .mode_fixup     = tilcdc_crtc_mode_fixup,
+       .atomic_check   = tilcdc_crtc_atomic_check,
+       .atomic_enable  = tilcdc_crtc_atomic_enable,
+       .atomic_disable = tilcdc_crtc_atomic_disable,
+};
+
 void tilcdc_crtc_set_panel_info(struct drm_crtc *crtc,
                const struct tilcdc_panel_info *info)
 {
index e1868776da2524be333c33f89cb4864ccdf11043..96457fe2b8d5bc404a29b005c155f42d4f6e3524 100644 (file)
@@ -202,7 +202,6 @@ static void tilcdc_fini(struct drm_device *dev)
 
        drm_irq_uninstall(dev);
        drm_mode_config_cleanup(dev);
-       tilcdc_remove_external_device(dev);
 
        if (priv->clk)
                clk_put(priv->clk);
index ead5122166699be40787974f49f5c13a03491a90..35558bbd5cd8840e5f51915f2c712b9ea35299b2 100644 (file)
@@ -89,7 +89,6 @@ struct tilcdc_drm_private {
 
        struct drm_encoder *external_encoder;
        struct drm_connector *external_connector;
-       const struct drm_connector_helper_funcs *connector_funcs;
 
        bool is_registered;
        bool is_componentized;
@@ -171,7 +170,6 @@ void tilcdc_crtc_set_panel_info(struct drm_crtc *crtc,
                const struct tilcdc_panel_info *info);
 void tilcdc_crtc_set_simulate_vesa_sync(struct drm_crtc *crtc,
                                        bool simulate_vesa_sync);
-int tilcdc_crtc_mode_valid(struct drm_crtc *crtc, struct drm_display_mode *mode);
 int tilcdc_crtc_max_width(struct drm_crtc *crtc);
 void tilcdc_crtc_shutdown(struct drm_crtc *crtc);
 int tilcdc_crtc_update_fb(struct drm_crtc *crtc,
index b4eaf9bc87f8e171246f4585dbfd470c114468f4..a2f623550ce3709d0cd340e7458702418ce61291 100644 (file)
@@ -40,64 +40,6 @@ static const struct tilcdc_panel_info panel_info_default = {
                .raster_order           = 0,
 };
 
-static int tilcdc_external_mode_valid(struct drm_connector *connector,
-                                     struct drm_display_mode *mode)
-{
-       struct tilcdc_drm_private *priv = connector->dev->dev_private;
-       int ret;
-
-       ret = tilcdc_crtc_mode_valid(priv->crtc, mode);
-       if (ret != MODE_OK)
-               return ret;
-
-       BUG_ON(priv->external_connector != connector);
-       BUG_ON(!priv->connector_funcs);
-
-       /* If the connector has its own mode_valid call it. */
-       if (!IS_ERR(priv->connector_funcs) &&
-           priv->connector_funcs->mode_valid)
-               return priv->connector_funcs->mode_valid(connector, mode);
-
-       return MODE_OK;
-}
-
-static int tilcdc_add_external_connector(struct drm_device *dev,
-                                        struct drm_connector *connector)
-{
-       struct tilcdc_drm_private *priv = dev->dev_private;
-       struct drm_connector_helper_funcs *connector_funcs;
-
-       /* There should never be more than one connector */
-       if (WARN_ON(priv->external_connector))
-               return -EINVAL;
-
-       priv->external_connector = connector;
-       connector_funcs = devm_kzalloc(dev->dev, sizeof(*connector_funcs),
-                                      GFP_KERNEL);
-       if (!connector_funcs)
-               return -ENOMEM;
-
-       /* connector->helper_private contains always struct
-        * connector_helper_funcs pointer. For tilcdc crtc to have a
-        * say if a specific mode is Ok, we need to install our own
-        * helper functions. In our helper functions we copy
-        * everything else but use our own mode_valid() (above).
-        */
-       if (connector->helper_private) {
-               priv->connector_funcs = connector->helper_private;
-               *connector_funcs = *priv->connector_funcs;
-       } else {
-               priv->connector_funcs = ERR_PTR(-ENOENT);
-       }
-       connector_funcs->mode_valid = tilcdc_external_mode_valid;
-       drm_connector_helper_add(connector, connector_funcs);
-
-       dev_dbg(dev->dev, "External connector '%s' connected\n",
-               connector->name);
-
-       return 0;
-}
-
 static
 struct drm_connector *tilcdc_encoder_find_connector(struct drm_device *ddev,
                                                    struct drm_encoder *encoder)
@@ -118,7 +60,6 @@ struct drm_connector *tilcdc_encoder_find_connector(struct drm_device *ddev,
 int tilcdc_add_component_encoder(struct drm_device *ddev)
 {
        struct tilcdc_drm_private *priv = ddev->dev_private;
-       struct drm_connector *connector;
        struct drm_encoder *encoder;
 
        list_for_each_entry(encoder, &ddev->mode_config.encoder_list, head)
@@ -130,28 +71,17 @@ int tilcdc_add_component_encoder(struct drm_device *ddev)
                return -ENODEV;
        }
 
-       connector = tilcdc_encoder_find_connector(ddev, encoder);
+       priv->external_connector =
+               tilcdc_encoder_find_connector(ddev, encoder);
 
-       if (!connector)
+       if (!priv->external_connector)
                return -ENODEV;
 
        /* Only tda998x is supported at the moment. */
        tilcdc_crtc_set_simulate_vesa_sync(priv->crtc, true);
        tilcdc_crtc_set_panel_info(priv->crtc, &panel_info_tda998x);
 
-       return tilcdc_add_external_connector(ddev, connector);
-}
-
-void tilcdc_remove_external_device(struct drm_device *dev)
-{
-       struct tilcdc_drm_private *priv = dev->dev_private;
-
-       /* Restore the original helper functions, if any. */
-       if (IS_ERR(priv->connector_funcs))
-               drm_connector_helper_add(priv->external_connector, NULL);
-       else if (priv->connector_funcs)
-               drm_connector_helper_add(priv->external_connector,
-                                        priv->connector_funcs);
+       return 0;
 }
 
 static const struct drm_encoder_funcs tilcdc_external_encoder_funcs = {
@@ -162,7 +92,6 @@ static
 int tilcdc_attach_bridge(struct drm_device *ddev, struct drm_bridge *bridge)
 {
        struct tilcdc_drm_private *priv = ddev->dev_private;
-       struct drm_connector *connector;
        int ret;
 
        priv->external_encoder->possible_crtcs = BIT(0);
@@ -175,13 +104,12 @@ int tilcdc_attach_bridge(struct drm_device *ddev, struct drm_bridge *bridge)
 
        tilcdc_crtc_set_panel_info(priv->crtc, &panel_info_default);
 
-       connector = tilcdc_encoder_find_connector(ddev, priv->external_encoder);
-       if (!connector)
+       priv->external_connector =
+               tilcdc_encoder_find_connector(ddev, priv->external_encoder);
+       if (!priv->external_connector)
                return -ENODEV;
 
-       ret = tilcdc_add_external_connector(ddev, connector);
-
-       return ret;
+       return 0;
 }
 
 int tilcdc_attach_external_device(struct drm_device *ddev)
index 763d18f006c74b92cef695165631283072844616..a28b9df68c8fdb883d6ebd4c89288e8d921c8c0f 100644 (file)
@@ -19,7 +19,6 @@
 #define __TILCDC_EXTERNAL_H__
 
 int tilcdc_add_component_encoder(struct drm_device *dev);
-void tilcdc_remove_external_device(struct drm_device *dev);
 int tilcdc_get_external_components(struct device *dev,
                                   struct component_match **match);
 int tilcdc_attach_external_device(struct drm_device *ddev);
index 096a33f12c615239460ffba7bdc26fc7ef290aad..253c555e2997459a4f8eef9f86b8f00f1182b9dd 100644 (file)
@@ -174,14 +174,6 @@ static int panel_connector_get_modes(struct drm_connector *connector)
        return i;
 }
 
-static int panel_connector_mode_valid(struct drm_connector *connector,
-                 struct drm_display_mode *mode)
-{
-       struct tilcdc_drm_private *priv = connector->dev->dev_private;
-       /* our only constraints are what the crtc can generate: */
-       return tilcdc_crtc_mode_valid(priv->crtc, mode);
-}
-
 static struct drm_encoder *panel_connector_best_encoder(
                struct drm_connector *connector)
 {
@@ -199,7 +191,6 @@ static const struct drm_connector_funcs panel_connector_funcs = {
 
 static const struct drm_connector_helper_funcs panel_connector_helper_funcs = {
        .get_modes          = panel_connector_get_modes,
-       .mode_valid         = panel_connector_mode_valid,
        .best_encoder       = panel_connector_best_encoder,
 };
 
index daebf1aa6b0a841dc28d8b681e591b5445a116c1..54c6d825b1a0624419b1b53152809c9b456f01b7 100644 (file)
@@ -183,14 +183,6 @@ static int tfp410_connector_get_modes(struct drm_connector *connector)
        return ret;
 }
 
-static int tfp410_connector_mode_valid(struct drm_connector *connector,
-                 struct drm_display_mode *mode)
-{
-       struct tilcdc_drm_private *priv = connector->dev->dev_private;
-       /* our only constraints are what the crtc can generate: */
-       return tilcdc_crtc_mode_valid(priv->crtc, mode);
-}
-
 static struct drm_encoder *tfp410_connector_best_encoder(
                struct drm_connector *connector)
 {
@@ -209,7 +201,6 @@ static const struct drm_connector_funcs tfp410_connector_funcs = {
 
 static const struct drm_connector_helper_funcs tfp410_connector_helper_funcs = {
        .get_modes          = tfp410_connector_get_modes,
-       .mode_valid         = tfp410_connector_mode_valid,
        .best_encoder       = tfp410_connector_best_encoder,
 };