Skip to content

Commit

Permalink
OMAPDSS: cleanup dss_recheck_connections further
Browse files Browse the repository at this point in the history
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 <tomi.valkeinen@ti.com>
  • Loading branch information
Tomi Valkeinen committed Sep 18, 2012
1 parent 6b41785 commit 5eeb55f
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 40 deletions.
5 changes: 0 additions & 5 deletions drivers/video/omap2/dss/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand Down
62 changes: 60 additions & 2 deletions drivers/video/omap2/dss/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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)
Expand Down
1 change: 0 additions & 1 deletion drivers/video/omap2/dss/dss.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
32 changes: 0 additions & 32 deletions drivers/video/omap2/dss/overlay.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5eeb55f

Please sign in to comment.