From 8768a52f8f53e6f54bce77faade1007d4142fa7c Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Thu, 6 Sep 2012 13:57:39 +0300 Subject: [PATCH 1/8] OMAPDSS: omap_dss_register_device() doesn't take display index We used to have all the displays of the board in one list, and we made a "displayX" directory in the sysfs, where X was the index of the display in the list. This doesn't work anymore with device tree, as there's no single list to get the number from, and it doesn't work very well even with non-DT as we need to do some tricks to get the index nowadays. This patch changes omap_dss_register_device() so that it doesn't take disp_num as a parameter anymore, but uses a private increasing counter for the display number. Signed-off-by: Tomi Valkeinen --- drivers/video/omap2/dss/core.c | 11 ++++++----- drivers/video/omap2/dss/dpi.c | 2 +- drivers/video/omap2/dss/dsi.c | 2 +- drivers/video/omap2/dss/dss.h | 2 +- drivers/video/omap2/dss/hdmi.c | 2 +- drivers/video/omap2/dss/rfbi.c | 2 +- drivers/video/omap2/dss/sdi.c | 2 +- drivers/video/omap2/dss/venc.c | 2 +- 8 files changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/video/omap2/dss/core.c b/drivers/video/omap2/dss/core.c index 58bd9c27369d..20c8bc8291b4 100644 --- a/drivers/video/omap2/dss/core.c +++ b/drivers/video/omap2/dss/core.c @@ -450,16 +450,17 @@ static void omap_dss_dev_release(struct device *dev) reset_device(dev, 0); } -int omap_dss_register_device(struct omap_dss_device *dssdev, - struct device *parent, int disp_num) -{ - WARN_ON(!dssdev->driver_name); +static int disp_num_counter; +int omap_dss_register_device(struct omap_dss_device *dssdev, + struct device *parent) +{ reset_device(&dssdev->dev, 1); + dssdev->dev.bus = &dss_bus_type; dssdev->dev.parent = parent; dssdev->dev.release = omap_dss_dev_release; - dev_set_name(&dssdev->dev, "display%d", disp_num); + dev_set_name(&dssdev->dev, "display%d", disp_num_counter++); return device_register(&dssdev->dev); } diff --git a/drivers/video/omap2/dss/dpi.c b/drivers/video/omap2/dss/dpi.c index 5ccce9b69e42..703fc1d8ec80 100644 --- a/drivers/video/omap2/dss/dpi.c +++ b/drivers/video/omap2/dss/dpi.c @@ -388,7 +388,7 @@ static void __init dpi_probe_pdata(struct platform_device *pdev) continue; } - r = omap_dss_register_device(dssdev, &pdev->dev, i); + r = omap_dss_register_device(dssdev, &pdev->dev); if (r) DSSERR("device %s register failed: %d\n", dssdev->name, r); diff --git a/drivers/video/omap2/dss/dsi.c b/drivers/video/omap2/dss/dsi.c index 8d815e39e45d..f7078fc90459 100644 --- a/drivers/video/omap2/dss/dsi.c +++ b/drivers/video/omap2/dss/dsi.c @@ -5027,7 +5027,7 @@ static void __init dsi_probe_pdata(struct platform_device *dsidev) continue; } - r = omap_dss_register_device(dssdev, &dsidev->dev, i); + r = omap_dss_register_device(dssdev, &dsidev->dev); if (r) DSSERR("device %s register failed: %d\n", dssdev->name, r); diff --git a/drivers/video/omap2/dss/dss.h b/drivers/video/omap2/dss/dss.h index 5e9fd7691728..7bac8ee078ad 100644 --- a/drivers/video/omap2/dss/dss.h +++ b/drivers/video/omap2/dss/dss.h @@ -185,7 +185,7 @@ int dss_set_min_bus_tput(struct device *dev, unsigned long tput); int dss_debugfs_create_file(const char *name, void (*write)(struct seq_file *)); int omap_dss_register_device(struct omap_dss_device *dssdev, - struct device *parent, int disp_num); + struct device *parent); void omap_dss_unregister_device(struct omap_dss_device *dssdev); void omap_dss_unregister_child_devices(struct device *parent); diff --git a/drivers/video/omap2/dss/hdmi.c b/drivers/video/omap2/dss/hdmi.c index 83f18458a406..bb07143a2d79 100644 --- a/drivers/video/omap2/dss/hdmi.c +++ b/drivers/video/omap2/dss/hdmi.c @@ -923,7 +923,7 @@ static void __init hdmi_probe_pdata(struct platform_device *pdev) continue; } - r = omap_dss_register_device(dssdev, &pdev->dev, i); + r = omap_dss_register_device(dssdev, &pdev->dev); if (r) DSSERR("device %s register failed: %d\n", dssdev->name, r); diff --git a/drivers/video/omap2/dss/rfbi.c b/drivers/video/omap2/dss/rfbi.c index 2e520d3085c8..845b4e70a28e 100644 --- a/drivers/video/omap2/dss/rfbi.c +++ b/drivers/video/omap2/dss/rfbi.c @@ -959,7 +959,7 @@ static void __init rfbi_probe_pdata(struct platform_device *pdev) continue; } - r = omap_dss_register_device(dssdev, &pdev->dev, i); + r = omap_dss_register_device(dssdev, &pdev->dev); if (r) DSSERR("device %s register failed: %d\n", dssdev->name, r); diff --git a/drivers/video/omap2/dss/sdi.c b/drivers/video/omap2/dss/sdi.c index 66c8de4365d6..c9a9045e19f2 100644 --- a/drivers/video/omap2/dss/sdi.c +++ b/drivers/video/omap2/dss/sdi.c @@ -212,7 +212,7 @@ static void __init sdi_probe_pdata(struct platform_device *pdev) continue; } - r = omap_dss_register_device(dssdev, &pdev->dev, i); + r = omap_dss_register_device(dssdev, &pdev->dev); if (r) DSSERR("device %s register failed: %d\n", dssdev->name, r); diff --git a/drivers/video/omap2/dss/venc.c b/drivers/video/omap2/dss/venc.c index 17b31029a793..60bfc5801636 100644 --- a/drivers/video/omap2/dss/venc.c +++ b/drivers/video/omap2/dss/venc.c @@ -752,7 +752,7 @@ static void __init venc_probe_pdata(struct platform_device *pdev) continue; } - r = omap_dss_register_device(dssdev, &pdev->dev, i); + r = omap_dss_register_device(dssdev, &pdev->dev); if (r) DSSERR("device %s register failed: %d\n", dssdev->name, r); From 6a03fca96e4d4d010be52e11fc7b8ab89da9d2cf Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Thu, 6 Sep 2012 14:26:10 +0300 Subject: [PATCH 2/8] OMAPDSS: Add dss_get_default_display_name() Add function dss_get_default_display_name() which returns the name of the default display, given from the board file or via module parameters. The default display name can be used by output drivers to decide which display is the wanted one. Signed-off-by: Tomi Valkeinen --- drivers/video/omap2/dss/core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/video/omap2/dss/core.c b/drivers/video/omap2/dss/core.c index 20c8bc8291b4..315f557f1d1a 100644 --- a/drivers/video/omap2/dss/core.c +++ b/drivers/video/omap2/dss/core.c @@ -57,6 +57,11 @@ bool dss_debug; module_param_named(debug, dss_debug, bool, 0644); #endif +const char *dss_get_default_display_name(void) +{ + return core.default_display_name; +} + /* REGULATORS */ struct regulator *dss_get_vdds_dsi(void) From 1521653c72596aaf1899c8d79a3f541f79ff238b Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Thu, 6 Sep 2012 14:29:31 +0300 Subject: [PATCH 3/8] OMAPDSS: register only one display device per output We have boards with multiple panel devices connected to the same physical output, of which only one panel can be enabled at one time. Examples of these are Overo, where you can use different daughter boards that have different LCDs, and 3430SDP which has an LCD and a DVI output and a physical switch to select the active display. These are supported by omapdss so that we add all the possible display devices at probe, but the displays are inactive until somebody enables one. At this point the panel driver starts using the DSS, thus reserving the physcal resource and excluding the other panels. This is problematic: - Panel drivers can't allocate their resources properly at probe(), because the resources can be shared with other panels. Thus they can be only reserved at enable time. - Managing this in omapdss is confusing. It's not natural to have child devices, which may not even exist (for example, a daughterboard that is not connected). Only some boards have multiple displays per output, and of those, only very few have possibility of switching the display during runtime. Because of the above points: - We don't want to make omapdss and all the panel drivers more complex just because some boards have complex setups. - Only few boards support runtime switching, and afaik even then it's not required. So we don't need to support runtime switching. Thus we'll change to a model where we will have only one display device per output and this cannot be (currently) changed at runtime. We'll still have the possibility to select the display from multiple options during boot with the default display option. This patch accomplishes the above by changing how the output drivers register the display device. Instead of registering all the devices given from the board file, we'll only register one. If the default display option is set, the output driver selects that display from its displays. If the default display is not set, or the default display is not one of the output's displays, the output driver selects the first display. Signed-off-by: Tomi Valkeinen --- drivers/video/omap2/dss/dpi.c | 49 ++++++++++++++++++++++------- drivers/video/omap2/dss/dsi.c | 53 +++++++++++++++++++++++-------- drivers/video/omap2/dss/dss.h | 1 + drivers/video/omap2/dss/hdmi.c | 57 +++++++++++++++++++++++++--------- drivers/video/omap2/dss/rfbi.c | 49 ++++++++++++++++++++++------- drivers/video/omap2/dss/sdi.c | 49 ++++++++++++++++++++++------- drivers/video/omap2/dss/venc.c | 49 ++++++++++++++++++++++------- 7 files changed, 236 insertions(+), 71 deletions(-) diff --git a/drivers/video/omap2/dss/dpi.c b/drivers/video/omap2/dss/dpi.c index 703fc1d8ec80..6f9a199a68a2 100644 --- a/drivers/video/omap2/dss/dpi.c +++ b/drivers/video/omap2/dss/dpi.c @@ -371,10 +371,14 @@ static int __init dpi_init_display(struct omap_dss_device *dssdev) return 0; } -static void __init dpi_probe_pdata(struct platform_device *pdev) +static struct omap_dss_device * __init dpi_find_dssdev(struct platform_device *pdev) { struct omap_dss_board_info *pdata = pdev->dev.platform_data; - int i, r; + const char *def_disp_name = dss_get_default_display_name(); + struct omap_dss_device *def_dssdev; + int i; + + def_dssdev = NULL; for (i = 0; i < pdata->num_devices; ++i) { struct omap_dss_device *dssdev = pdata->devices[i]; @@ -382,16 +386,39 @@ static void __init dpi_probe_pdata(struct platform_device *pdev) if (dssdev->type != OMAP_DISPLAY_TYPE_DPI) continue; - r = dpi_init_display(dssdev); - if (r) { - DSSERR("device %s init failed: %d\n", dssdev->name, r); - continue; - } + if (def_dssdev == NULL) + def_dssdev = dssdev; - r = omap_dss_register_device(dssdev, &pdev->dev); - if (r) - DSSERR("device %s register failed: %d\n", - dssdev->name, r); + if (def_disp_name != NULL && + strcmp(dssdev->name, def_disp_name) == 0) { + def_dssdev = dssdev; + break; + } + } + + return def_dssdev; +} + +static void __init dpi_probe_pdata(struct platform_device *pdev) +{ + struct omap_dss_device *dssdev; + int r; + + dssdev = dpi_find_dssdev(pdev); + + if (!dssdev) + return; + + r = dpi_init_display(dssdev); + if (r) { + DSSERR("device %s init failed: %d\n", dssdev->name, r); + return; + } + + r = omap_dss_register_device(dssdev, &pdev->dev); + if (r) { + DSSERR("device %s register failed: %d\n", dssdev->name, r); + return; } } diff --git a/drivers/video/omap2/dss/dsi.c b/drivers/video/omap2/dss/dsi.c index f7078fc90459..ee9ae526f5c1 100644 --- a/drivers/video/omap2/dss/dsi.c +++ b/drivers/video/omap2/dss/dsi.c @@ -5006,11 +5006,15 @@ static void dsi_put_clocks(struct platform_device *dsidev) clk_put(dsi->sys_clk); } -static void __init dsi_probe_pdata(struct platform_device *dsidev) +static struct omap_dss_device * __init dsi_find_dssdev(struct platform_device *pdev) { - struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); - struct omap_dss_board_info *pdata = dsidev->dev.platform_data; - int i, r; + struct omap_dss_board_info *pdata = pdev->dev.platform_data; + struct dsi_data *dsi = dsi_get_dsidrv_data(pdev); + const char *def_disp_name = dss_get_default_display_name(); + struct omap_dss_device *def_dssdev; + int i; + + def_dssdev = NULL; for (i = 0; i < pdata->num_devices; ++i) { struct omap_dss_device *dssdev = pdata->devices[i]; @@ -5021,16 +5025,39 @@ static void __init dsi_probe_pdata(struct platform_device *dsidev) if (dssdev->phy.dsi.module != dsi->module_id) continue; - r = dsi_init_display(dssdev); - if (r) { - DSSERR("device %s init failed: %d\n", dssdev->name, r); - continue; - } + if (def_dssdev == NULL) + def_dssdev = dssdev; - r = omap_dss_register_device(dssdev, &dsidev->dev); - if (r) - DSSERR("device %s register failed: %d\n", - dssdev->name, r); + if (def_disp_name != NULL && + strcmp(dssdev->name, def_disp_name) == 0) { + def_dssdev = dssdev; + break; + } + } + + return def_dssdev; +} + +static void __init dsi_probe_pdata(struct platform_device *dsidev) +{ + struct omap_dss_device *dssdev; + int r; + + dssdev = dsi_find_dssdev(dsidev); + + if (!dssdev) + return; + + r = dsi_init_display(dssdev); + if (r) { + DSSERR("device %s init failed: %d\n", dssdev->name, r); + return; + } + + r = omap_dss_register_device(dssdev, &dsidev->dev); + if (r) { + DSSERR("device %s register failed: %d\n", dssdev->name, r); + return; } } diff --git a/drivers/video/omap2/dss/dss.h b/drivers/video/omap2/dss/dss.h index 7bac8ee078ad..a977826d850c 100644 --- a/drivers/video/omap2/dss/dss.h +++ b/drivers/video/omap2/dss/dss.h @@ -175,6 +175,7 @@ struct seq_file; struct platform_device; /* core */ +const char *dss_get_default_display_name(void); struct bus_type *dss_get_bus(void); struct regulator *dss_get_vdds_dsi(void); struct regulator *dss_get_vdds_sdi(void); diff --git a/drivers/video/omap2/dss/hdmi.c b/drivers/video/omap2/dss/hdmi.c index bb07143a2d79..76d100b975e0 100644 --- a/drivers/video/omap2/dss/hdmi.c +++ b/drivers/video/omap2/dss/hdmi.c @@ -901,32 +901,61 @@ int hdmi_audio_config(struct omap_dss_audio *audio) #endif -static void __init hdmi_probe_pdata(struct platform_device *pdev) +static struct omap_dss_device * __init hdmi_find_dssdev(struct platform_device *pdev) { struct omap_dss_board_info *pdata = pdev->dev.platform_data; - int r, i; + const char *def_disp_name = dss_get_default_display_name(); + struct omap_dss_device *def_dssdev; + int i; + + def_dssdev = NULL; for (i = 0; i < pdata->num_devices; ++i) { struct omap_dss_device *dssdev = pdata->devices[i]; - struct omap_dss_hdmi_data *priv = dssdev->data; if (dssdev->type != OMAP_DISPLAY_TYPE_HDMI) continue; - hdmi.ct_cp_hpd_gpio = priv->ct_cp_hpd_gpio; - hdmi.ls_oe_gpio = priv->ls_oe_gpio; - hdmi.hpd_gpio = priv->hpd_gpio; + if (def_dssdev == NULL) + def_dssdev = dssdev; - r = hdmi_init_display(dssdev); - if (r) { - DSSERR("device %s init failed: %d\n", dssdev->name, r); - continue; + if (def_disp_name != NULL && + strcmp(dssdev->name, def_disp_name) == 0) { + def_dssdev = dssdev; + break; } + } - r = omap_dss_register_device(dssdev, &pdev->dev); - if (r) - DSSERR("device %s register failed: %d\n", - dssdev->name, r); + return def_dssdev; +} + +static void __init hdmi_probe_pdata(struct platform_device *pdev) +{ + struct omap_dss_device *dssdev; + struct omap_dss_hdmi_data *priv; + int r; + + dssdev = hdmi_find_dssdev(pdev); + + if (!dssdev) + return; + + priv = dssdev->data; + + hdmi.ct_cp_hpd_gpio = priv->ct_cp_hpd_gpio; + hdmi.ls_oe_gpio = priv->ls_oe_gpio; + hdmi.hpd_gpio = priv->hpd_gpio; + + r = hdmi_init_display(dssdev); + if (r) { + DSSERR("device %s init failed: %d\n", dssdev->name, r); + return; + } + + r = omap_dss_register_device(dssdev, &pdev->dev); + if (r) { + DSSERR("device %s register failed: %d\n", dssdev->name, r); + return; } } diff --git a/drivers/video/omap2/dss/rfbi.c b/drivers/video/omap2/dss/rfbi.c index 845b4e70a28e..1127037cb9d5 100644 --- a/drivers/video/omap2/dss/rfbi.c +++ b/drivers/video/omap2/dss/rfbi.c @@ -942,10 +942,14 @@ static int __init rfbi_init_display(struct omap_dss_device *dssdev) return 0; } -static void __init rfbi_probe_pdata(struct platform_device *pdev) +static struct omap_dss_device * __init rfbi_find_dssdev(struct platform_device *pdev) { struct omap_dss_board_info *pdata = pdev->dev.platform_data; - int i, r; + const char *def_disp_name = dss_get_default_display_name(); + struct omap_dss_device *def_dssdev; + int i; + + def_dssdev = NULL; for (i = 0; i < pdata->num_devices; ++i) { struct omap_dss_device *dssdev = pdata->devices[i]; @@ -953,16 +957,39 @@ static void __init rfbi_probe_pdata(struct platform_device *pdev) if (dssdev->type != OMAP_DISPLAY_TYPE_DBI) continue; - r = rfbi_init_display(dssdev); - if (r) { - DSSERR("device %s init failed: %d\n", dssdev->name, r); - continue; - } + if (def_dssdev == NULL) + def_dssdev = dssdev; - r = omap_dss_register_device(dssdev, &pdev->dev); - if (r) - DSSERR("device %s register failed: %d\n", - dssdev->name, r); + if (def_disp_name != NULL && + strcmp(dssdev->name, def_disp_name) == 0) { + def_dssdev = dssdev; + break; + } + } + + return def_dssdev; +} + +static void __init rfbi_probe_pdata(struct platform_device *pdev) +{ + struct omap_dss_device *dssdev; + int r; + + dssdev = rfbi_find_dssdev(pdev); + + if (!dssdev) + return; + + r = rfbi_init_display(dssdev); + if (r) { + DSSERR("device %s init failed: %d\n", dssdev->name, r); + return; + } + + r = omap_dss_register_device(dssdev, &pdev->dev); + if (r) { + DSSERR("device %s register failed: %d\n", dssdev->name, r); + return; } } diff --git a/drivers/video/omap2/dss/sdi.c b/drivers/video/omap2/dss/sdi.c index c9a9045e19f2..0aaa7f35874c 100644 --- a/drivers/video/omap2/dss/sdi.c +++ b/drivers/video/omap2/dss/sdi.c @@ -195,10 +195,14 @@ static int __init sdi_init_display(struct omap_dss_device *dssdev) return 0; } -static void __init sdi_probe_pdata(struct platform_device *pdev) +static struct omap_dss_device * __init sdi_find_dssdev(struct platform_device *pdev) { struct omap_dss_board_info *pdata = pdev->dev.platform_data; - int i, r; + const char *def_disp_name = dss_get_default_display_name(); + struct omap_dss_device *def_dssdev; + int i; + + def_dssdev = NULL; for (i = 0; i < pdata->num_devices; ++i) { struct omap_dss_device *dssdev = pdata->devices[i]; @@ -206,16 +210,39 @@ static void __init sdi_probe_pdata(struct platform_device *pdev) if (dssdev->type != OMAP_DISPLAY_TYPE_SDI) continue; - r = sdi_init_display(dssdev); - if (r) { - DSSERR("device %s init failed: %d\n", dssdev->name, r); - continue; - } + if (def_dssdev == NULL) + def_dssdev = dssdev; - r = omap_dss_register_device(dssdev, &pdev->dev); - if (r) - DSSERR("device %s register failed: %d\n", - dssdev->name, r); + if (def_disp_name != NULL && + strcmp(dssdev->name, def_disp_name) == 0) { + def_dssdev = dssdev; + break; + } + } + + return def_dssdev; +} + +static void __init sdi_probe_pdata(struct platform_device *pdev) +{ + struct omap_dss_device *dssdev; + int r; + + dssdev = sdi_find_dssdev(pdev); + + if (!dssdev) + return; + + r = sdi_init_display(dssdev); + if (r) { + DSSERR("device %s init failed: %d\n", dssdev->name, r); + return; + } + + r = omap_dss_register_device(dssdev, &pdev->dev); + if (r) { + DSSERR("device %s register failed: %d\n", dssdev->name, r); + return; } } diff --git a/drivers/video/omap2/dss/venc.c b/drivers/video/omap2/dss/venc.c index 60bfc5801636..b9c0a8f468d2 100644 --- a/drivers/video/omap2/dss/venc.c +++ b/drivers/video/omap2/dss/venc.c @@ -735,10 +735,14 @@ static void venc_put_clocks(void) clk_put(venc.tv_dac_clk); } -static void __init venc_probe_pdata(struct platform_device *pdev) +static struct omap_dss_device * __init venc_find_dssdev(struct platform_device *pdev) { struct omap_dss_board_info *pdata = pdev->dev.platform_data; - int r, i; + const char *def_disp_name = dss_get_default_display_name(); + struct omap_dss_device *def_dssdev; + int i; + + def_dssdev = NULL; for (i = 0; i < pdata->num_devices; ++i) { struct omap_dss_device *dssdev = pdata->devices[i]; @@ -746,16 +750,39 @@ static void __init venc_probe_pdata(struct platform_device *pdev) if (dssdev->type != OMAP_DISPLAY_TYPE_VENC) continue; - r = venc_init_display(dssdev); - if (r) { - DSSERR("device %s init failed: %d\n", dssdev->name, r); - continue; - } + if (def_dssdev == NULL) + def_dssdev = dssdev; - r = omap_dss_register_device(dssdev, &pdev->dev); - if (r) - DSSERR("device %s register failed: %d\n", - dssdev->name, r); + if (def_disp_name != NULL && + strcmp(dssdev->name, def_disp_name) == 0) { + def_dssdev = dssdev; + break; + } + } + + return def_dssdev; +} + +static void __init venc_probe_pdata(struct platform_device *pdev) +{ + struct omap_dss_device *dssdev; + int r; + + dssdev = venc_find_dssdev(pdev); + + if (!dssdev) + return; + + r = venc_init_display(dssdev); + if (r) { + DSSERR("device %s init failed: %d\n", dssdev->name, r); + return; + } + + r = omap_dss_register_device(dssdev, &pdev->dev); + if (r) { + DSSERR("device %s register failed: %d\n", dssdev->name, r); + return; } } From bcb226a9254d30c0c44bc724c22b7a5d3fadec6a Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Fri, 7 Sep 2012 15:21:36 +0300 Subject: [PATCH 4/8] OMAPDSS: explicitely initialize dssdev->channel for new displays HDMI and VENC outputs always use the DIGIT output from DISPC. The dssdev struct contains "channel" field which is used to specify the DISPC output for the display, but this was not used for HDMI and VENC. This patch fills the channel field explicitely for HDMI and VENC displays so that we can always rely on the channel field. Signed-off-by: Tomi Valkeinen --- drivers/video/omap2/dss/hdmi.c | 2 ++ drivers/video/omap2/dss/venc.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drivers/video/omap2/dss/hdmi.c b/drivers/video/omap2/dss/hdmi.c index 76d100b975e0..3b10e18efa22 100644 --- a/drivers/video/omap2/dss/hdmi.c +++ b/drivers/video/omap2/dss/hdmi.c @@ -946,6 +946,8 @@ static void __init hdmi_probe_pdata(struct platform_device *pdev) hdmi.ls_oe_gpio = priv->ls_oe_gpio; hdmi.hpd_gpio = priv->hpd_gpio; + dssdev->channel = OMAP_DSS_CHANNEL_DIGIT; + r = hdmi_init_display(dssdev); if (r) { DSSERR("device %s init failed: %d\n", dssdev->name, r); diff --git a/drivers/video/omap2/dss/venc.c b/drivers/video/omap2/dss/venc.c index b9c0a8f468d2..88fa6ea77e74 100644 --- a/drivers/video/omap2/dss/venc.c +++ b/drivers/video/omap2/dss/venc.c @@ -773,6 +773,8 @@ static void __init venc_probe_pdata(struct platform_device *pdev) if (!dssdev) return; + dssdev->channel = OMAP_DSS_CHANNEL_DIGIT; + r = venc_init_display(dssdev); if (r) { DSSERR("device %s init failed: %d\n", dssdev->name, r); From 47eb6763ff63126e34785be0ea5f365180595024 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Fri, 7 Sep 2012 15:44:30 +0300 Subject: [PATCH 5/8] OMAPDSS: handle errors in dss_init_device Add error handling to dss_init_device(), which has, for some reason, been missing. Signed-off-by: Tomi Valkeinen --- drivers/video/omap2/dss/core.c | 4 +++- drivers/video/omap2/dss/display.c | 23 ++++++++++++++++++----- drivers/video/omap2/dss/dss.h | 2 +- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/drivers/video/omap2/dss/core.c b/drivers/video/omap2/dss/core.c index 315f557f1d1a..9315ece90ff1 100644 --- a/drivers/video/omap2/dss/core.c +++ b/drivers/video/omap2/dss/core.c @@ -358,7 +358,9 @@ static int dss_driver_probe(struct device *dev) dev_name(dev), dssdev->driver_name, dssdrv->driver.name); - dss_init_device(core.pdev, dssdev); + r = dss_init_device(core.pdev, dssdev); + if (r) + return r; force = core.default_display_name && strcmp(core.default_display_name, dssdev->name) == 0; diff --git a/drivers/video/omap2/dss/display.c b/drivers/video/omap2/dss/display.c index 5f09d503d619..f7190109bd91 100644 --- a/drivers/video/omap2/dss/display.c +++ b/drivers/video/omap2/dss/display.c @@ -320,26 +320,39 @@ void omapdss_default_get_timings(struct omap_dss_device *dssdev, } EXPORT_SYMBOL(omapdss_default_get_timings); -void dss_init_device(struct platform_device *pdev, +int dss_init_device(struct platform_device *pdev, struct omap_dss_device *dssdev) { struct device_attribute *attr; - int i; - int r; + int i, r; /* create device sysfs files */ i = 0; while ((attr = display_sysfs_attrs[i++]) != NULL) { r = device_create_file(&dssdev->dev, attr); - if (r) + if (r) { + for (i = i - 2; i >= 0; i--) { + attr = display_sysfs_attrs[i]; + device_remove_file(&dssdev->dev, attr); + } + DSSERR("failed to create sysfs file\n"); + return r; + } } /* create display? sysfs links */ r = sysfs_create_link(&pdev->dev.kobj, &dssdev->dev.kobj, dev_name(&dssdev->dev)); - if (r) + if (r) { + while ((attr = display_sysfs_attrs[i++]) != NULL) + device_remove_file(&dssdev->dev, attr); + DSSERR("failed to create sysfs display link\n"); + return r; + } + + return 0; } void dss_uninit_device(struct platform_device *pdev, diff --git a/drivers/video/omap2/dss/dss.h b/drivers/video/omap2/dss/dss.h index a977826d850c..98e82731c60a 100644 --- a/drivers/video/omap2/dss/dss.h +++ b/drivers/video/omap2/dss/dss.h @@ -228,7 +228,7 @@ int dss_suspend_all_devices(void); int dss_resume_all_devices(void); void dss_disable_all_devices(void); -void dss_init_device(struct platform_device *pdev, +int dss_init_device(struct platform_device *pdev, struct omap_dss_device *dssdev); void dss_uninit_device(struct platform_device *pdev, struct omap_dss_device *dssdev); From 6b41785836f184df585e33cd6b940852fb9299ed Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Fri, 7 Sep 2012 15:21:56 +0300 Subject: [PATCH 6/8] OMAPDSS: cleanup dss_recheck_connections dss_recheck_connections is quite a mess. With the previous commit that initializes the channel field for HDMI and VENC displays, we can greatly simplify the dss_recheck_connections. Signed-off-by: Tomi Valkeinen --- drivers/video/omap2/dss/overlay.c | 49 ++++--------------------------- 1 file changed, 6 insertions(+), 43 deletions(-) diff --git a/drivers/video/omap2/dss/overlay.c b/drivers/video/omap2/dss/overlay.c index e3d406875afd..1bf05efffe13 100644 --- a/drivers/video/omap2/dss/overlay.c +++ b/drivers/video/omap2/dss/overlay.c @@ -109,52 +109,15 @@ void dss_init_overlays(struct platform_device *pdev) * selected, connect always. */ void dss_recheck_connections(struct omap_dss_device *dssdev, bool force) { - int i; - struct omap_overlay_manager *lcd_mgr; - struct omap_overlay_manager *tv_mgr; - struct omap_overlay_manager *lcd2_mgr = NULL; - struct omap_overlay_manager *lcd3_mgr = NULL; struct omap_overlay_manager *mgr = NULL; + int i; - lcd_mgr = omap_dss_get_overlay_manager(OMAP_DSS_CHANNEL_LCD); - tv_mgr = omap_dss_get_overlay_manager(OMAP_DSS_CHANNEL_DIGIT); - if (dss_has_feature(FEAT_MGR_LCD3)) - lcd3_mgr = omap_dss_get_overlay_manager(OMAP_DSS_CHANNEL_LCD3); - if (dss_has_feature(FEAT_MGR_LCD2)) - lcd2_mgr = omap_dss_get_overlay_manager(OMAP_DSS_CHANNEL_LCD2); + mgr = omap_dss_get_overlay_manager(dssdev->channel); - if (dssdev->channel == OMAP_DSS_CHANNEL_LCD3) { - if (!lcd3_mgr->device || force) { - if (lcd3_mgr->device) - lcd3_mgr->unset_device(lcd3_mgr); - lcd3_mgr->set_device(lcd3_mgr, dssdev); - mgr = lcd3_mgr; - } - } else if (dssdev->channel == OMAP_DSS_CHANNEL_LCD2) { - if (!lcd2_mgr->device || force) { - if (lcd2_mgr->device) - lcd2_mgr->unset_device(lcd2_mgr); - lcd2_mgr->set_device(lcd2_mgr, dssdev); - mgr = lcd2_mgr; - } - } else if (dssdev->type != OMAP_DISPLAY_TYPE_VENC - && dssdev->type != OMAP_DISPLAY_TYPE_HDMI) { - if (!lcd_mgr->device || force) { - if (lcd_mgr->device) - lcd_mgr->unset_device(lcd_mgr); - lcd_mgr->set_device(lcd_mgr, dssdev); - mgr = lcd_mgr; - } - } - - if (dssdev->type == OMAP_DISPLAY_TYPE_VENC - || dssdev->type == OMAP_DISPLAY_TYPE_HDMI) { - if (!tv_mgr->device || force) { - if (tv_mgr->device) - tv_mgr->unset_device(tv_mgr); - tv_mgr->set_device(tv_mgr, dssdev); - mgr = tv_mgr; - } + if (!mgr->device || force) { + if (mgr->device) + mgr->unset_device(mgr); + mgr->set_device(mgr, dssdev); } if (mgr) { From 5eeb55f8703d2af3181599c085b21ce023a0f942 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Fri, 7 Sep 2012 15:48:45 +0300 Subject: [PATCH 7/8] OMAPDSS: cleanup dss_recheck_connections further Cleanup dss_recheck_connections, move and rename it to a static dss_init_connections function inside display.c. Improve the function to return errors, and implement a matching dss_uninit_connections that can be used to free the mgr->dssdev link. Signed-off-by: Tomi Valkeinen --- drivers/video/omap2/dss/core.c | 5 --- drivers/video/omap2/dss/display.c | 62 ++++++++++++++++++++++++++++++- drivers/video/omap2/dss/dss.h | 1 - drivers/video/omap2/dss/overlay.c | 32 ---------------- 4 files changed, 60 insertions(+), 40 deletions(-) diff --git a/drivers/video/omap2/dss/core.c b/drivers/video/omap2/dss/core.c index 9315ece90ff1..c4fd7687f3a3 100644 --- a/drivers/video/omap2/dss/core.c +++ b/drivers/video/omap2/dss/core.c @@ -352,7 +352,6 @@ static int dss_driver_probe(struct device *dev) int r; struct omap_dss_driver *dssdrv = to_dss_driver(dev->driver); struct omap_dss_device *dssdev = to_dss_device(dev); - bool force; DSSDBG("driver_probe: dev %s/%s, drv %s\n", dev_name(dev), dssdev->driver_name, @@ -362,10 +361,6 @@ static int dss_driver_probe(struct device *dev) if (r) return r; - force = core.default_display_name && - strcmp(core.default_display_name, dssdev->name) == 0; - dss_recheck_connections(dssdev, force); - r = dssdrv->probe(dssdev); if (r) { diff --git a/drivers/video/omap2/dss/display.c b/drivers/video/omap2/dss/display.c index f7190109bd91..db83ae81a713 100644 --- a/drivers/video/omap2/dss/display.c +++ b/drivers/video/omap2/dss/display.c @@ -320,11 +320,66 @@ void omapdss_default_get_timings(struct omap_dss_device *dssdev, } EXPORT_SYMBOL(omapdss_default_get_timings); +/* + * Connect dssdev to a manager if the manager is free or if force is specified. + * Connect all overlays to that manager if they are free or if force is + * specified. + */ +static int dss_init_connections(struct omap_dss_device *dssdev, bool force) +{ + struct omap_overlay_manager *mgr; + int i, r; + + WARN_ON(dssdev->manager); + + mgr = omap_dss_get_overlay_manager(dssdev->channel); + + if (mgr->device && !force) + return 0; + + if (mgr->device) + mgr->unset_device(mgr); + + r = mgr->set_device(mgr, dssdev); + if (r) { + DSSERR("failed to set initial manager\n"); + return r; + } + + for (i = 0; i < omap_dss_get_num_overlays(); ++i) { + struct omap_overlay *ovl = omap_dss_get_overlay(i); + + if (!ovl->manager || force) { + if (ovl->manager) + ovl->unset_manager(ovl); + + r = ovl->set_manager(ovl, mgr); + if (r) { + DSSERR("failed to set initial overlay\n"); + return r; + } + } + } + + return 0; +} + +static void dss_uninit_connections(struct omap_dss_device *dssdev) +{ + if (dssdev->manager) + dssdev->manager->unset_device(dssdev->manager); +} + int dss_init_device(struct platform_device *pdev, struct omap_dss_device *dssdev) { struct device_attribute *attr; int i, r; + const char *def_disp_name = dss_get_default_display_name(); + bool force; + + force = def_disp_name && strcmp(def_disp_name, dssdev->name) == 0; + dss_init_connections(dssdev, force); /* create device sysfs files */ i = 0; @@ -336,6 +391,8 @@ int dss_init_device(struct platform_device *pdev, device_remove_file(&dssdev->dev, attr); } + dss_uninit_connections(dssdev); + DSSERR("failed to create sysfs file\n"); return r; } @@ -348,6 +405,8 @@ int dss_init_device(struct platform_device *pdev, while ((attr = display_sysfs_attrs[i++]) != NULL) device_remove_file(&dssdev->dev, attr); + dss_uninit_connections(dssdev); + DSSERR("failed to create sysfs display link\n"); return r; } @@ -366,8 +425,7 @@ void dss_uninit_device(struct platform_device *pdev, while ((attr = display_sysfs_attrs[i++]) != NULL) device_remove_file(&dssdev->dev, attr); - if (dssdev->manager) - dssdev->manager->unset_device(dssdev->manager); + dss_uninit_connections(dssdev); } static int dss_suspend_device(struct device *dev, void *data) diff --git a/drivers/video/omap2/dss/dss.h b/drivers/video/omap2/dss/dss.h index 98e82731c60a..7a3fea66b411 100644 --- a/drivers/video/omap2/dss/dss.h +++ b/drivers/video/omap2/dss/dss.h @@ -263,7 +263,6 @@ void dss_manager_kobj_uninit(struct omap_overlay_manager *mgr); void dss_init_overlays(struct platform_device *pdev); void dss_uninit_overlays(struct platform_device *pdev); void dss_overlay_setup_dispc_manager(struct omap_overlay_manager *mgr); -void dss_recheck_connections(struct omap_dss_device *dssdev, bool force); int dss_ovl_simple_check(struct omap_overlay *ovl, const struct omap_overlay_info *info); int dss_ovl_check(struct omap_overlay *ovl, struct omap_overlay_info *info, diff --git a/drivers/video/omap2/dss/overlay.c b/drivers/video/omap2/dss/overlay.c index 1bf05efffe13..52455a0609cb 100644 --- a/drivers/video/omap2/dss/overlay.c +++ b/drivers/video/omap2/dss/overlay.c @@ -105,38 +105,6 @@ void dss_init_overlays(struct platform_device *pdev) } } -/* connect overlays to the new device, if not already connected. if force - * selected, connect always. */ -void dss_recheck_connections(struct omap_dss_device *dssdev, bool force) -{ - struct omap_overlay_manager *mgr = NULL; - int i; - - mgr = omap_dss_get_overlay_manager(dssdev->channel); - - if (!mgr->device || force) { - if (mgr->device) - mgr->unset_device(mgr); - mgr->set_device(mgr, dssdev); - } - - if (mgr) { - dispc_runtime_get(); - - for (i = 0; i < dss_feat_get_num_ovls(); i++) { - struct omap_overlay *ovl; - ovl = omap_dss_get_overlay(i); - if (!ovl->manager || force) { - if (ovl->manager) - ovl->unset_manager(ovl); - ovl->set_manager(ovl, mgr); - } - } - - dispc_runtime_put(); - } -} - void dss_uninit_overlays(struct platform_device *pdev) { int i; From 5274484b821bb2cf34a697624ef14084c31b16ce Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Mon, 10 Sep 2012 13:58:29 +0300 Subject: [PATCH 8/8] OMAPDSS: alloc dssdevs dynamically We currently create omap_dss_devices statically in board files, and use those devices directly in the omapdss driver. This model prevents us from having the platform data (which the dssdevs in board files practically are) as read-only, and it's also different than what we will use with device tree. This patch changes the model to be in line with DT model: we allocate the dssdevs dynamically, and initialize them according to the data in the board file's dssdev (basically we memcopy the dssdev fields). The allocation and registration is done in the following steps in the output drivers: - Use dss_alloc_and_init_device to allocate and initialize the device. The function uses kalloc and device_initialize to accomplish this. - Call dss_copy_device_pdata to copy the data from the board file's dssdev - Use dss_add_device to register the device. Signed-off-by: Tomi Valkeinen --- drivers/video/omap2/dss/core.c | 72 +++++++++++++++++----------------- drivers/video/omap2/dss/dpi.c | 17 ++++++-- drivers/video/omap2/dss/dsi.c | 15 +++++-- drivers/video/omap2/dss/dss.h | 11 ++++-- drivers/video/omap2/dss/hdmi.c | 15 +++++-- drivers/video/omap2/dss/rfbi.c | 17 ++++++-- drivers/video/omap2/dss/sdi.c | 17 ++++++-- drivers/video/omap2/dss/venc.c | 17 ++++++-- 8 files changed, 119 insertions(+), 62 deletions(-) diff --git a/drivers/video/omap2/dss/core.c b/drivers/video/omap2/dss/core.c index c4fd7687f3a3..b2af72dc20bd 100644 --- a/drivers/video/omap2/dss/core.c +++ b/drivers/video/omap2/dss/core.c @@ -33,6 +33,7 @@ #include #include #include +#include #include