OMAPDSS: split omap_dss_mgr_apply() to smaller funcs
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Fri, 4 Nov 2011 07:19:35 +0000 (09:19 +0200)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Fri, 2 Dec 2011 06:54:29 +0000 (08:54 +0200)
Split omap_dss_mgr_apply() into smaller functions for clarity.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
drivers/video/omap2/dss/manager.c

index 8423cf85f6828f7e8aae241a781823c998944975..d0d23157110b15bcc4037d1a1086163679e843fa 100644 (file)
@@ -993,107 +993,92 @@ end:
        spin_unlock(&dss_cache.lock);
 }
 
-static int omap_dss_mgr_apply(struct omap_overlay_manager *mgr)
+static int omap_dss_mgr_apply_ovl(struct omap_overlay *ovl)
 {
        struct overlay_cache_data *oc;
-       struct manager_cache_data *mc;
-       int i;
-       struct omap_overlay *ovl;
-       unsigned long flags;
-       int r;
-
-       DSSDBG("omap_dss_mgr_apply(%s)\n", mgr->name);
+       struct omap_dss_device *dssdev;
 
-       r = dispc_runtime_get();
-       if (r)
-               return r;
+       oc = &dss_cache.overlay_cache[ovl->id];
 
-       spin_lock_irqsave(&dss_cache.lock, flags);
+       if (ovl->manager_changed) {
+               ovl->manager_changed = false;
+               ovl->info_dirty  = true;
+       }
 
-       /* Configure overlays */
-       for (i = 0; i < omap_dss_get_num_overlays(); ++i) {
-               struct omap_dss_device *dssdev;
+       if (!overlay_enabled(ovl)) {
+               if (oc->enabled) {
+                       oc->enabled = false;
+                       oc->dirty = true;
+               }
+               return 0;
+       }
 
-               ovl = omap_dss_get_overlay(i);
+       if (!ovl->info_dirty)
+               return 0;
 
-               oc = &dss_cache.overlay_cache[ovl->id];
+       dssdev = ovl->manager->device;
 
-               if (ovl->manager_changed) {
-                       ovl->manager_changed = false;
-                       ovl->info_dirty  = true;
+       if (dss_check_overlay(ovl, dssdev)) {
+               if (oc->enabled) {
+                       oc->enabled = false;
+                       oc->dirty = true;
                }
+               return -EINVAL;
+       }
 
-               if (!overlay_enabled(ovl)) {
-                       if (oc->enabled) {
-                               oc->enabled = false;
-                               oc->dirty = true;
-                       }
-                       continue;
-               }
+       ovl->info_dirty = false;
+       oc->dirty = true;
+       oc->info = ovl->info;
 
-               if (!ovl->info_dirty)
-                       continue;
+       oc->channel = ovl->manager->id;
 
-               dssdev = ovl->manager->device;
+       oc->enabled = true;
 
-               if (dss_check_overlay(ovl, dssdev)) {
-                       if (oc->enabled) {
-                               oc->enabled = false;
-                               oc->dirty = true;
-                       }
-                       continue;
-               }
+       return 0;
+}
 
-               ovl->info_dirty = false;
-               oc->dirty = true;
-               oc->info = ovl->info;
+static void omap_dss_mgr_apply_mgr(struct omap_overlay_manager *mgr)
+{
+       struct manager_cache_data *mc;
 
-               oc->channel = ovl->manager->id;
+       mc = &dss_cache.manager_cache[mgr->id];
 
-               oc->enabled = true;
+       if (mgr->device_changed) {
+               mgr->device_changed = false;
+               mgr->info_dirty  = true;
        }
 
-       /* Configure managers */
-       list_for_each_entry(mgr, &manager_list, list) {
-               mc = &dss_cache.manager_cache[mgr->id];
-
-               if (mgr->device_changed) {
-                       mgr->device_changed = false;
-                       mgr->info_dirty  = true;
-               }
+       if (!mgr->info_dirty)
+               return;
 
-               if (!mgr->info_dirty)
-                       continue;
+       if (!mgr->device)
+               return;
 
-               if (!mgr->device)
-                       continue;
+       mgr->info_dirty = false;
+       mc->dirty = true;
+       mc->info = mgr->info;
 
-               mgr->info_dirty = false;
-               mc->dirty = true;
-               mc->info = mgr->info;
-
-               mc->manual_update = mgr_manual_update(mgr);
-       }
-
-       /* Configure overlay fifos */
-       for (i = 0; i < omap_dss_get_num_overlays(); ++i) {
-               struct omap_dss_device *dssdev;
-               u32 size, burst_size;
+       mc->manual_update = mgr_manual_update(mgr);
+}
 
-               ovl = omap_dss_get_overlay(i);
+static void omap_dss_mgr_apply_ovl_fifos(struct omap_overlay *ovl)
+{
+       struct overlay_cache_data *oc;
+       struct omap_dss_device *dssdev;
+       u32 size, burst_size;
 
-               oc = &dss_cache.overlay_cache[ovl->id];
+       oc = &dss_cache.overlay_cache[ovl->id];
 
-               if (!oc->enabled)
-                       continue;
+       if (!oc->enabled)
+               return;
 
-               dssdev = ovl->manager->device;
+       dssdev = ovl->manager->device;
 
-               size = dispc_ovl_get_fifo_size(ovl->id);
+       size = dispc_ovl_get_fifo_size(ovl->id);
 
-               burst_size = dispc_ovl_get_burst_size(ovl->id);
+       burst_size = dispc_ovl_get_burst_size(ovl->id);
 
-               switch (dssdev->type) {
+       switch (dssdev->type) {
                case OMAP_DISPLAY_TYPE_DPI:
                case OMAP_DISPLAY_TYPE_DBI:
                case OMAP_DISPLAY_TYPE_SDI:
@@ -1112,7 +1097,42 @@ static int omap_dss_mgr_apply(struct omap_overlay_manager *mgr)
 #endif
                default:
                        BUG();
-               }
+       }
+}
+
+static int omap_dss_mgr_apply(struct omap_overlay_manager *mgr)
+{
+       int i, r;
+       unsigned long flags;
+
+       DSSDBG("omap_dss_mgr_apply(%s)\n", mgr->name);
+
+       r = dispc_runtime_get();
+       if (r)
+               return r;
+
+       spin_lock_irqsave(&dss_cache.lock, flags);
+
+       /* Configure overlays */
+       for (i = 0; i < omap_dss_get_num_overlays(); ++i) {
+               struct omap_overlay *ovl;
+
+               ovl = omap_dss_get_overlay(i);
+
+               omap_dss_mgr_apply_ovl(ovl);
+       }
+
+       /* Configure managers */
+       list_for_each_entry(mgr, &manager_list, list)
+               omap_dss_mgr_apply_mgr(mgr);
+
+       /* Configure overlay fifos */
+       for (i = 0; i < omap_dss_get_num_overlays(); ++i) {
+               struct omap_overlay *ovl;
+
+               ovl = omap_dss_get_overlay(i);
+
+               omap_dss_mgr_apply_ovl_fifos(ovl);
        }
 
        r = 0;