Index: trunk/psModules/src/camera/pmFPAConstruct.c
===================================================================
--- trunk/psModules/src/camera/pmFPAConstruct.c	(revision 15940)
+++ trunk/psModules/src/camera/pmFPAConstruct.c	(revision 16912)
@@ -415,37 +415,37 @@
     psArray *cellNames = NULL;      // Cell names
     psArray *cellTypes = NULL;      // Cell types
-    
+
     int nParsed = 0;
 
     switch (chipContents->type) {
       case PS_DATA_STRING: {
-	  nParsed = parseContent(&cellNames, &cellTypes, NULL, chipContents->data.str);
-	  break;
+          nParsed = parseContent(&cellNames, &cellTypes, NULL, chipContents->data.str);
+          break;
       }
       case PS_DATA_METADATA: {
-	  psMetadataIterator *iter = psMetadataIteratorAlloc(chipContents->data.md, PS_LIST_HEAD, NULL); // Iterator
-	  psMetadataItem *item;           // Item from iteration
-	  while ((item = psMetadataGetAndIncrement(iter))) {
-	      if (item->type != PS_DATA_STRING) {
-		  psWarning ("Item %s in camera format chip table is not of type STR.", item->name);
-		  continue;
-	      }
-	      nParsed += parseContent(&cellNames, &cellTypes, NULL, item->data.str);
-	  }
-	  psFree (iter);
-	  break;
+          psMetadataIterator *iter = psMetadataIteratorAlloc(chipContents->data.md, PS_LIST_HEAD, NULL); // Iterator
+          psMetadataItem *item;           // Item from iteration
+          while ((item = psMetadataGetAndIncrement(iter))) {
+              if (item->type != PS_DATA_STRING) {
+                  psWarning ("Item %s in camera format chip table is not of type STR.", item->name);
+                  continue;
+              }
+              nParsed += parseContent(&cellNames, &cellTypes, NULL, item->data.str);
+          }
+          psFree (iter);
+          break;
       }
       default:
-	psWarning ("Item %s in camera format chip table is not of type STR.", chipContents->name);
-	break;
+        psWarning ("Item %s in camera format chip table is not of type STR.", chipContents->name);
+        break;
     }
 
     if (nParsed == 0) {
-	psError(PS_ERR_BAD_PARAMETER_VALUE, false,
-		"Unable to parse chip contents (within %s in camera format) as cellName:cellType",
-		CHIP_TYPES);
-	psFree(cellNames);
-	psFree(cellTypes);
-	return false;
+        psError(PS_ERR_BAD_PARAMETER_VALUE, false,
+                "Unable to parse chip contents (within %s in camera format) as cellName:cellType",
+                CHIP_TYPES);
+        psFree(cellNames);
+        psFree(cellTypes);
+        return false;
     }
 
@@ -1349,4 +1349,46 @@
 }
 
+bool pmFPAAddSourceFromFormat(pmFPA *fpa, const char *fpaname, const psMetadata *format)
+{
+    PS_ASSERT_PTR_NON_NULL(fpa, false);
+    PS_ASSERT_METADATA_NON_NULL(format, false);
+
+    // Generate the correct structure
+    pmFPALevel phuLevel = pmFPAPHULevel(format); // Level at which PHU goes
+    pmFPAview *view = pmFPAviewAlloc(0);// View for current level
+    if (phuLevel == PM_FPA_LEVEL_FPA) {
+        if (!pmFPAAddSourceFromView(fpa, fpaname, view, format)) {
+            psError(PS_ERR_UNKNOWN, false, "Unable to add PHU to FPA.");
+            psFree(view);
+            return false;
+        }
+    } else {
+        pmChip *chip;                       // Chip from FPA
+        while ((chip = pmFPAviewNextChip(view, fpa, 1))) {
+            if (phuLevel == PM_FPA_LEVEL_CHIP) {
+                if (!pmFPAAddSourceFromView(fpa, fpaname, view, format)) {
+                    psError(PS_ERR_UNKNOWN, false, "Unable to add PHU to FPA.");
+                    psFree(view);
+                    return false;
+                }
+            } else {
+                pmCell *cell;                   // Cell from chip
+                while ((cell = pmFPAviewNextCell(view, fpa, 1))) {
+                    if (phuLevel == PM_FPA_LEVEL_CELL) {
+                        if (!pmFPAAddSourceFromView(fpa, fpaname, view, format)) {
+                            psError(PS_ERR_UNKNOWN, false, "Unable to add PHU to FPA.");
+                            psFree(view);
+                            return false;
+                        }
+                    }
+                }
+            }
+        }
+    }
+    psFree(view);
+
+    return true;
+}
+
 bool pmFPAAddSourceFromView(pmFPA *fpa, const char *fpaname, const pmFPAview *phuView,
                             const psMetadata *format)
