From 28120302c2fdf29b515c8cbd4e3a3867cb0cde7d Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 6 Jun 2018 00:55:48 +0300 Subject: [PATCH] drm/omap: Don't call .check_timings() operation recursively The .check_timings() operation is called recursively from the display device back to the output device. Most components just forward the operation to the previous component in the chain, resulting in lots of duplicated pass-through functions. To avoid that, iterate over the components manually. Signed-off-by: Laurent Pinchart Reviewed-by: Sebastian Reichel Signed-off-by: Tomi Valkeinen --- .../gpu/drm/omapdrm/displays/connector-analog-tv.c | 9 ------ drivers/gpu/drm/omapdrm/displays/connector-dvi.c | 9 ------ drivers/gpu/drm/omapdrm/displays/connector-hdmi.c | 9 ------ drivers/gpu/drm/omapdrm/displays/encoder-opa362.c | 11 -------- drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c | 9 ------ .../gpu/drm/omapdrm/displays/encoder-tpd12s015.c | 9 ------ drivers/gpu/drm/omapdrm/displays/panel-dpi.c | 9 ------ .../omapdrm/displays/panel-lgphilips-lb035q02.c | 9 ------ .../drm/omapdrm/displays/panel-nec-nl8048hl11.c | 9 ------ .../drm/omapdrm/displays/panel-sharp-ls037v7dw01.c | 9 ------ .../drm/omapdrm/displays/panel-sony-acx565akm.c | 9 ------ .../drm/omapdrm/displays/panel-tpo-td028ttec1.c | 9 ------ .../drm/omapdrm/displays/panel-tpo-td043mtea1.c | 9 ------ drivers/gpu/drm/omapdrm/omap_connector.c | 32 +++++++++++++--------- drivers/gpu/drm/omapdrm/omap_encoder.c | 20 +++++++++----- 15 files changed, 32 insertions(+), 139 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c index fb6d4fc..a9e2a36 100644 --- a/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c +++ b/drivers/gpu/drm/omapdrm/displays/connector-analog-tv.c @@ -109,14 +109,6 @@ static void tvc_get_timings(struct omap_dss_device *dssdev, *vm = ddata->vm; } -static int tvc_check_timings(struct omap_dss_device *dssdev, - struct videomode *vm) -{ - struct omap_dss_device *src = dssdev->src; - - return src->ops->check_timings(src, vm); -} - static const struct omap_dss_device_ops tvc_ops = { .connect = tvc_connect, .disconnect = tvc_disconnect, @@ -126,7 +118,6 @@ static const struct omap_dss_device_ops tvc_ops = { .set_timings = tvc_set_timings, .get_timings = tvc_get_timings, - .check_timings = tvc_check_timings, }; static int tvc_probe(struct platform_device *pdev) diff --git a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c index 5871872..a9e2f11 100644 --- a/drivers/gpu/drm/omapdrm/displays/connector-dvi.c +++ b/drivers/gpu/drm/omapdrm/displays/connector-dvi.c @@ -116,14 +116,6 @@ static void dvic_get_timings(struct omap_dss_device *dssdev, *vm = ddata->vm; } -static int dvic_check_timings(struct omap_dss_device *dssdev, - struct videomode *vm) -{ - struct omap_dss_device *src = dssdev->src; - - return src->ops->check_timings(src, vm); -} - static int dvic_ddc_read(struct i2c_adapter *adapter, unsigned char *buf, u16 count, u8 offset) { @@ -232,7 +224,6 @@ static const struct omap_dss_device_ops dvic_ops = { .set_timings = dvic_set_timings, .get_timings = dvic_get_timings, - .check_timings = dvic_check_timings, .read_edid = dvic_read_edid, .detect = dvic_detect, diff --git a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c index 898eb583..7e449f8 100644 --- a/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c +++ b/drivers/gpu/drm/omapdrm/displays/connector-hdmi.c @@ -114,14 +114,6 @@ static void hdmic_get_timings(struct omap_dss_device *dssdev, *vm = ddata->vm; } -static int hdmic_check_timings(struct omap_dss_device *dssdev, - struct videomode *vm) -{ - struct omap_dss_device *src = dssdev->src; - - return src->ops->check_timings(src, vm); -} - static bool hdmic_detect(struct omap_dss_device *dssdev) { struct panel_drv_data *ddata = to_panel_data(dssdev); @@ -161,7 +153,6 @@ static const struct omap_dss_device_ops hdmic_ops = { .set_timings = hdmic_set_timings, .get_timings = hdmic_get_timings, - .check_timings = hdmic_check_timings, .detect = hdmic_detect, .register_hpd_cb = hdmic_register_hpd_cb, diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c index 05d1286..bdf7961 100644 --- a/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c +++ b/drivers/gpu/drm/omapdrm/displays/encoder-opa362.c @@ -95,22 +95,11 @@ static void opa362_set_timings(struct omap_dss_device *dssdev, src->ops->set_timings(src, vm); } -static int opa362_check_timings(struct omap_dss_device *dssdev, - struct videomode *vm) -{ - struct omap_dss_device *src = dssdev->src; - - dev_dbg(dssdev->dev, "check_timings\n"); - - return src->ops->check_timings(src, vm); -} - static const struct omap_dss_device_ops opa362_ops = { .connect = opa362_connect, .disconnect = opa362_disconnect, .enable = opa362_enable, .disable = opa362_disable, - .check_timings = opa362_check_timings, .set_timings = opa362_set_timings, }; diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c index 56b78cd..c3ceee2 100644 --- a/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c +++ b/drivers/gpu/drm/omapdrm/displays/encoder-tfp410.c @@ -84,20 +84,11 @@ static void tfp410_set_timings(struct omap_dss_device *dssdev, src->ops->set_timings(src, vm); } -static int tfp410_check_timings(struct omap_dss_device *dssdev, - struct videomode *vm) -{ - struct omap_dss_device *src = dssdev->src; - - return src->ops->check_timings(src, vm); -} - static const struct omap_dss_device_ops tfp410_ops = { .connect = tfp410_connect, .disconnect = tfp410_disconnect, .enable = tfp410_enable, .disable = tfp410_disable, - .check_timings = tfp410_check_timings, .set_timings = tfp410_set_timings, }; diff --git a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c index 1e24559..4598e5c 100644 --- a/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c +++ b/drivers/gpu/drm/omapdrm/displays/encoder-tpd12s015.c @@ -99,14 +99,6 @@ static void tpd_set_timings(struct omap_dss_device *dssdev, src->ops->set_timings(src, vm); } -static int tpd_check_timings(struct omap_dss_device *dssdev, - struct videomode *vm) -{ - struct omap_dss_device *src = dssdev->src; - - return src->ops->check_timings(src, vm); -} - static bool tpd_detect(struct omap_dss_device *dssdev) { struct panel_drv_data *ddata = to_panel_data(dssdev); @@ -142,7 +134,6 @@ static const struct omap_dss_device_ops tpd_ops = { .disconnect = tpd_disconnect, .enable = tpd_enable, .disable = tpd_disable, - .check_timings = tpd_check_timings, .set_timings = tpd_set_timings, .detect = tpd_detect, .register_hpd_cb = tpd_register_hpd_cb, diff --git a/drivers/gpu/drm/omapdrm/displays/panel-dpi.c b/drivers/gpu/drm/omapdrm/displays/panel-dpi.c index 32efed4..e75600a 100644 --- a/drivers/gpu/drm/omapdrm/displays/panel-dpi.c +++ b/drivers/gpu/drm/omapdrm/displays/panel-dpi.c @@ -112,14 +112,6 @@ static void panel_dpi_get_timings(struct omap_dss_device *dssdev, *vm = ddata->vm; } -static int panel_dpi_check_timings(struct omap_dss_device *dssdev, - struct videomode *vm) -{ - struct omap_dss_device *src = dssdev->src; - - return src->ops->check_timings(src, vm); -} - static const struct omap_dss_device_ops panel_dpi_ops = { .connect = panel_dpi_connect, .disconnect = panel_dpi_disconnect, @@ -129,7 +121,6 @@ static const struct omap_dss_device_ops panel_dpi_ops = { .set_timings = panel_dpi_set_timings, .get_timings = panel_dpi_get_timings, - .check_timings = panel_dpi_check_timings, }; static int panel_dpi_probe_of(struct platform_device *pdev) diff --git a/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c b/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c index a211506..3c221f7 100644 --- a/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c +++ b/drivers/gpu/drm/omapdrm/displays/panel-lgphilips-lb035q02.c @@ -182,14 +182,6 @@ static void lb035q02_get_timings(struct omap_dss_device *dssdev, *vm = ddata->vm; } -static int lb035q02_check_timings(struct omap_dss_device *dssdev, - struct videomode *vm) -{ - struct omap_dss_device *src = dssdev->src; - - return src->ops->check_timings(src, vm); -} - static const struct omap_dss_device_ops lb035q02_ops = { .connect = lb035q02_connect, .disconnect = lb035q02_disconnect, @@ -199,7 +191,6 @@ static const struct omap_dss_device_ops lb035q02_ops = { .set_timings = lb035q02_set_timings, .get_timings = lb035q02_get_timings, - .check_timings = lb035q02_check_timings, }; static int lb035q02_probe_of(struct spi_device *spi) diff --git a/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c b/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c index 1b2f33d..78ff18c 100644 --- a/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c +++ b/drivers/gpu/drm/omapdrm/displays/panel-nec-nl8048hl11.c @@ -175,14 +175,6 @@ static void nec_8048_get_timings(struct omap_dss_device *dssdev, *vm = ddata->vm; } -static int nec_8048_check_timings(struct omap_dss_device *dssdev, - struct videomode *vm) -{ - struct omap_dss_device *src = dssdev->src; - - return src->ops->check_timings(src, vm); -} - static const struct omap_dss_device_ops nec_8048_ops = { .connect = nec_8048_connect, .disconnect = nec_8048_disconnect, @@ -192,7 +184,6 @@ static const struct omap_dss_device_ops nec_8048_ops = { .set_timings = nec_8048_set_timings, .get_timings = nec_8048_get_timings, - .check_timings = nec_8048_check_timings, }; static int nec_8048_probe(struct spi_device *spi) diff --git a/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c b/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c index fbf88aa..47e97db 100644 --- a/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c +++ b/drivers/gpu/drm/omapdrm/displays/panel-sharp-ls037v7dw01.c @@ -145,14 +145,6 @@ static void sharp_ls_get_timings(struct omap_dss_device *dssdev, *vm = ddata->vm; } -static int sharp_ls_check_timings(struct omap_dss_device *dssdev, - struct videomode *vm) -{ - struct omap_dss_device *src = dssdev->src; - - return src->ops->check_timings(src, vm); -} - static const struct omap_dss_device_ops sharp_ls_ops = { .connect = sharp_ls_connect, .disconnect = sharp_ls_disconnect, @@ -162,7 +154,6 @@ static const struct omap_dss_device_ops sharp_ls_ops = { .set_timings = sharp_ls_set_timings, .get_timings = sharp_ls_get_timings, - .check_timings = sharp_ls_check_timings, }; static int sharp_ls_get_gpio_of(struct device *dev, int index, int val, diff --git a/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c b/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c index 7e99d54..1ec3b1e 100644 --- a/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c +++ b/drivers/gpu/drm/omapdrm/displays/panel-sony-acx565akm.c @@ -648,14 +648,6 @@ static void acx565akm_get_timings(struct omap_dss_device *dssdev, *vm = ddata->vm; } -static int acx565akm_check_timings(struct omap_dss_device *dssdev, - struct videomode *vm) -{ - struct omap_dss_device *src = dssdev->src; - - return src->ops->check_timings(src, vm); -} - static const struct omap_dss_device_ops acx565akm_ops = { .connect = acx565akm_connect, .disconnect = acx565akm_disconnect, @@ -665,7 +657,6 @@ static const struct omap_dss_device_ops acx565akm_ops = { .set_timings = acx565akm_set_timings, .get_timings = acx565akm_get_timings, - .check_timings = acx565akm_check_timings, }; static int acx565akm_probe(struct spi_device *spi) diff --git a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c index e8c73ad..cff1a1a 100644 --- a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c +++ b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td028ttec1.c @@ -314,14 +314,6 @@ static void td028ttec1_panel_get_timings(struct omap_dss_device *dssdev, *vm = ddata->vm; } -static int td028ttec1_panel_check_timings(struct omap_dss_device *dssdev, - struct videomode *vm) -{ - struct omap_dss_device *src = dssdev->src; - - return src->ops->check_timings(src, vm); -} - static const struct omap_dss_device_ops td028ttec1_ops = { .connect = td028ttec1_panel_connect, .disconnect = td028ttec1_panel_disconnect, @@ -331,7 +323,6 @@ static const struct omap_dss_device_ops td028ttec1_ops = { .set_timings = td028ttec1_panel_set_timings, .get_timings = td028ttec1_panel_get_timings, - .check_timings = td028ttec1_panel_check_timings, }; static int td028ttec1_panel_probe(struct spi_device *spi) diff --git a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c index ae7a40a..513e846 100644 --- a/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c +++ b/drivers/gpu/drm/omapdrm/displays/panel-tpo-td043mtea1.c @@ -388,14 +388,6 @@ static void tpo_td043_get_timings(struct omap_dss_device *dssdev, *vm = ddata->vm; } -static int tpo_td043_check_timings(struct omap_dss_device *dssdev, - struct videomode *vm) -{ - struct omap_dss_device *src = dssdev->src; - - return src->ops->check_timings(src, vm); -} - static const struct omap_dss_device_ops tpo_td043_ops = { .connect = tpo_td043_connect, .disconnect = tpo_td043_disconnect, @@ -405,7 +397,6 @@ static const struct omap_dss_device_ops tpo_td043_ops = { .set_timings = tpo_td043_set_timings, .get_timings = tpo_td043_get_timings, - .check_timings = tpo_td043_check_timings, }; static int tpo_td043_probe(struct spi_device *spi) diff --git a/drivers/gpu/drm/omapdrm/omap_connector.c b/drivers/gpu/drm/omapdrm/omap_connector.c index b58d9a0..302f2ed 100644 --- a/drivers/gpu/drm/omapdrm/omap_connector.c +++ b/drivers/gpu/drm/omapdrm/omap_connector.c @@ -252,7 +252,7 @@ static int omap_connector_mode_valid(struct drm_connector *connector, struct drm_display_mode *mode) { struct omap_connector *omap_connector = to_omap_connector(connector); - struct omap_dss_device *dssdev = omap_connector->display; + struct omap_dss_device *dssdev; struct videomode vm = {0}; struct drm_device *dev = connector->dev; struct drm_display_mode *new_mode; @@ -261,21 +261,27 @@ static int omap_connector_mode_valid(struct drm_connector *connector, drm_display_mode_to_videomode(mode, &vm); mode->vrefresh = drm_mode_vrefresh(mode); - r = dssdev->ops->check_timings(dssdev, &vm); - if (!r) { - /* check if vrefresh is still valid */ - new_mode = drm_mode_duplicate(dev, mode); - - if (!new_mode) - return MODE_BAD; + for (dssdev = omap_connector->output; dssdev; dssdev = dssdev->next) { + if (!dssdev->ops->check_timings) + continue; - new_mode->clock = vm.pixelclock / 1000; - new_mode->vrefresh = 0; - if (mode->vrefresh == drm_mode_vrefresh(new_mode)) - ret = MODE_OK; - drm_mode_destroy(dev, new_mode); + r = dssdev->ops->check_timings(dssdev, &vm); + if (r) + goto done; } + /* check if vrefresh is still valid */ + new_mode = drm_mode_duplicate(dev, mode); + if (!new_mode) + return MODE_BAD; + + new_mode->clock = vm.pixelclock / 1000; + new_mode->vrefresh = 0; + if (mode->vrefresh == drm_mode_vrefresh(new_mode)) + ret = MODE_OK; + drm_mode_destroy(dev, new_mode); + +done: DBG("connector: mode %s: " "%d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x", (ret == MODE_OK) ? "valid" : "invalid", diff --git a/drivers/gpu/drm/omapdrm/omap_encoder.c b/drivers/gpu/drm/omapdrm/omap_encoder.c index a6dce48..bb010c2 100644 --- a/drivers/gpu/drm/omapdrm/omap_encoder.c +++ b/drivers/gpu/drm/omapdrm/omap_encoder.c @@ -98,17 +98,23 @@ static int omap_encoder_update(struct drm_encoder *encoder, { struct drm_device *dev = encoder->dev; struct omap_encoder *omap_encoder = to_omap_encoder(encoder); - struct omap_dss_device *dssdev = omap_encoder->display; + struct omap_dss_device *display = omap_encoder->display; + struct omap_dss_device *dssdev; int ret; - ret = dssdev->ops->check_timings(dssdev, vm); - if (ret) { - dev_err(dev->dev, "invalid timings: %d\n", ret); - return ret; + for (dssdev = omap_encoder->output; dssdev; dssdev = dssdev->next) { + if (!dssdev->ops->check_timings) + continue; + + ret = dssdev->ops->check_timings(dssdev, vm); + if (ret) { + dev_err(dev->dev, "invalid timings: %d\n", ret); + return ret; + } } - if (dssdev->ops->set_timings) - dssdev->ops->set_timings(dssdev, vm); + if (display->ops->set_timings) + display->ops->set_timings(display, vm); return 0; } -- 2.7.4