Commit 57d83965 authored by Jyri Sarha's avatar Jyri Sarha

drm/tilcdc: Remove obsolete crtc_mode_valid() hack

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: default avatarJyri Sarha <jsarha@ti.com>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Link: https://patchwork.freedesktop.org/patch/msgid/ <5c4dcb5b1e7975bd2b7ca86f7addf219cd0f9a06.1564750248.git.jsarha@ti.com
parent 93386368
...@@ -650,9 +650,6 @@ static bool tilcdc_crtc_mode_fixup(struct drm_crtc *crtc, ...@@ -650,9 +650,6 @@ static bool tilcdc_crtc_mode_fixup(struct drm_crtc *crtc,
static int tilcdc_crtc_atomic_check(struct drm_crtc *crtc, static int tilcdc_crtc_atomic_check(struct drm_crtc *crtc,
struct drm_crtc_state *state) struct drm_crtc_state *state)
{ {
struct drm_display_mode *mode = &state->mode;
int ret;
/* If we are not active we don't care */ /* If we are not active we don't care */
if (!state->active) if (!state->active)
return 0; return 0;
...@@ -664,12 +661,6 @@ static int tilcdc_crtc_atomic_check(struct drm_crtc *crtc, ...@@ -664,12 +661,6 @@ static int tilcdc_crtc_atomic_check(struct drm_crtc *crtc,
return -EINVAL; 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; return 0;
} }
...@@ -721,13 +712,6 @@ static const struct drm_crtc_funcs tilcdc_crtc_funcs = { ...@@ -721,13 +712,6 @@ static const struct drm_crtc_funcs tilcdc_crtc_funcs = {
.disable_vblank = tilcdc_crtc_disable_vblank, .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) int tilcdc_crtc_max_width(struct drm_crtc *crtc)
{ {
struct drm_device *dev = crtc->dev; struct drm_device *dev = crtc->dev;
...@@ -742,7 +726,9 @@ int tilcdc_crtc_max_width(struct drm_crtc *crtc) ...@@ -742,7 +726,9 @@ int tilcdc_crtc_max_width(struct drm_crtc *crtc)
return max_width; 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; struct tilcdc_drm_private *priv = crtc->dev->dev_private;
unsigned int bandwidth; unsigned int bandwidth;
...@@ -830,6 +816,14 @@ int tilcdc_crtc_mode_valid(struct drm_crtc *crtc, struct drm_display_mode *mode) ...@@ -830,6 +816,14 @@ int tilcdc_crtc_mode_valid(struct drm_crtc *crtc, struct drm_display_mode *mode)
return MODE_OK; 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, void tilcdc_crtc_set_panel_info(struct drm_crtc *crtc,
const struct tilcdc_panel_info *info) const struct tilcdc_panel_info *info)
{ {
......
...@@ -199,7 +199,6 @@ static void tilcdc_fini(struct drm_device *dev) ...@@ -199,7 +199,6 @@ static void tilcdc_fini(struct drm_device *dev)
drm_kms_helper_poll_fini(dev); drm_kms_helper_poll_fini(dev);
drm_irq_uninstall(dev); drm_irq_uninstall(dev);
drm_mode_config_cleanup(dev); drm_mode_config_cleanup(dev);
tilcdc_remove_external_device(dev);
if (priv->clk) if (priv->clk)
clk_put(priv->clk); clk_put(priv->clk);
......
...@@ -77,7 +77,6 @@ struct tilcdc_drm_private { ...@@ -77,7 +77,6 @@ struct tilcdc_drm_private {
struct drm_encoder *external_encoder; struct drm_encoder *external_encoder;
struct drm_connector *external_connector; struct drm_connector *external_connector;
const struct drm_connector_helper_funcs *connector_funcs;
bool is_registered; bool is_registered;
bool is_componentized; bool is_componentized;
...@@ -159,7 +158,6 @@ void tilcdc_crtc_set_panel_info(struct drm_crtc *crtc, ...@@ -159,7 +158,6 @@ void tilcdc_crtc_set_panel_info(struct drm_crtc *crtc,
const struct tilcdc_panel_info *info); const struct tilcdc_panel_info *info);
void tilcdc_crtc_set_simulate_vesa_sync(struct drm_crtc *crtc, void tilcdc_crtc_set_simulate_vesa_sync(struct drm_crtc *crtc,
bool simulate_vesa_sync); 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); int tilcdc_crtc_max_width(struct drm_crtc *crtc);
void tilcdc_crtc_shutdown(struct drm_crtc *crtc); void tilcdc_crtc_shutdown(struct drm_crtc *crtc);
int tilcdc_crtc_update_fb(struct drm_crtc *crtc, int tilcdc_crtc_update_fb(struct drm_crtc *crtc,
......
...@@ -38,64 +38,6 @@ static const struct tilcdc_panel_info panel_info_default = { ...@@ -38,64 +38,6 @@ static const struct tilcdc_panel_info panel_info_default = {
.raster_order = 0, .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 static
struct drm_connector *tilcdc_encoder_find_connector(struct drm_device *ddev, struct drm_connector *tilcdc_encoder_find_connector(struct drm_device *ddev,
struct drm_encoder *encoder) struct drm_encoder *encoder)
...@@ -116,7 +58,6 @@ struct drm_connector *tilcdc_encoder_find_connector(struct drm_device *ddev, ...@@ -116,7 +58,6 @@ struct drm_connector *tilcdc_encoder_find_connector(struct drm_device *ddev,
int tilcdc_add_component_encoder(struct drm_device *ddev) int tilcdc_add_component_encoder(struct drm_device *ddev)
{ {
struct tilcdc_drm_private *priv = ddev->dev_private; struct tilcdc_drm_private *priv = ddev->dev_private;
struct drm_connector *connector;
struct drm_encoder *encoder; struct drm_encoder *encoder;
list_for_each_entry(encoder, &ddev->mode_config.encoder_list, head) list_for_each_entry(encoder, &ddev->mode_config.encoder_list, head)
...@@ -128,28 +69,17 @@ int tilcdc_add_component_encoder(struct drm_device *ddev) ...@@ -128,28 +69,17 @@ int tilcdc_add_component_encoder(struct drm_device *ddev)
return -ENODEV; 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; return -ENODEV;
/* Only tda998x is supported at the moment. */ /* Only tda998x is supported at the moment. */
tilcdc_crtc_set_simulate_vesa_sync(priv->crtc, true); tilcdc_crtc_set_simulate_vesa_sync(priv->crtc, true);
tilcdc_crtc_set_panel_info(priv->crtc, &panel_info_tda998x); tilcdc_crtc_set_panel_info(priv->crtc, &panel_info_tda998x);
return tilcdc_add_external_connector(ddev, connector); return 0;
}
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);
} }
static const struct drm_encoder_funcs tilcdc_external_encoder_funcs = { static const struct drm_encoder_funcs tilcdc_external_encoder_funcs = {
...@@ -160,7 +90,6 @@ static ...@@ -160,7 +90,6 @@ static
int tilcdc_attach_bridge(struct drm_device *ddev, struct drm_bridge *bridge) int tilcdc_attach_bridge(struct drm_device *ddev, struct drm_bridge *bridge)
{ {
struct tilcdc_drm_private *priv = ddev->dev_private; struct tilcdc_drm_private *priv = ddev->dev_private;
struct drm_connector *connector;
int ret; int ret;
priv->external_encoder->possible_crtcs = BIT(0); priv->external_encoder->possible_crtcs = BIT(0);
...@@ -173,13 +102,12 @@ int tilcdc_attach_bridge(struct drm_device *ddev, struct drm_bridge *bridge) ...@@ -173,13 +102,12 @@ int tilcdc_attach_bridge(struct drm_device *ddev, struct drm_bridge *bridge)
tilcdc_crtc_set_panel_info(priv->crtc, &panel_info_default); tilcdc_crtc_set_panel_info(priv->crtc, &panel_info_default);
connector = tilcdc_encoder_find_connector(ddev, priv->external_encoder); priv->external_connector =
if (!connector) tilcdc_encoder_find_connector(ddev, priv->external_encoder);
if (!priv->external_connector)
return -ENODEV; return -ENODEV;
ret = tilcdc_add_external_connector(ddev, connector); return 0;
return ret;
} }
int tilcdc_attach_external_device(struct drm_device *ddev) int tilcdc_attach_external_device(struct drm_device *ddev)
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#define __TILCDC_EXTERNAL_H__ #define __TILCDC_EXTERNAL_H__
int tilcdc_add_component_encoder(struct drm_device *dev); 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, int tilcdc_get_external_components(struct device *dev,
struct component_match **match); struct component_match **match);
int tilcdc_attach_external_device(struct drm_device *ddev); int tilcdc_attach_external_device(struct drm_device *ddev);
......
...@@ -163,14 +163,6 @@ static int panel_connector_get_modes(struct drm_connector *connector) ...@@ -163,14 +163,6 @@ static int panel_connector_get_modes(struct drm_connector *connector)
return i; 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( static struct drm_encoder *panel_connector_best_encoder(
struct drm_connector *connector) struct drm_connector *connector)
{ {
...@@ -188,7 +180,6 @@ static const struct drm_connector_funcs panel_connector_funcs = { ...@@ -188,7 +180,6 @@ static const struct drm_connector_funcs panel_connector_funcs = {
static const struct drm_connector_helper_funcs panel_connector_helper_funcs = { static const struct drm_connector_helper_funcs panel_connector_helper_funcs = {
.get_modes = panel_connector_get_modes, .get_modes = panel_connector_get_modes,
.mode_valid = panel_connector_mode_valid,
.best_encoder = panel_connector_best_encoder, .best_encoder = panel_connector_best_encoder,
}; };
......
...@@ -175,14 +175,6 @@ static int tfp410_connector_get_modes(struct drm_connector *connector) ...@@ -175,14 +175,6 @@ static int tfp410_connector_get_modes(struct drm_connector *connector)
return ret; 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( static struct drm_encoder *tfp410_connector_best_encoder(
struct drm_connector *connector) struct drm_connector *connector)
{ {
...@@ -201,7 +193,6 @@ static const struct drm_connector_funcs tfp410_connector_funcs = { ...@@ -201,7 +193,6 @@ static const struct drm_connector_funcs tfp410_connector_funcs = {
static const struct drm_connector_helper_funcs tfp410_connector_helper_funcs = { static const struct drm_connector_helper_funcs tfp410_connector_helper_funcs = {
.get_modes = tfp410_connector_get_modes, .get_modes = tfp410_connector_get_modes,
.mode_valid = tfp410_connector_mode_valid,
.best_encoder = tfp410_connector_best_encoder, .best_encoder = tfp410_connector_best_encoder,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment