Add support for DDR shared heap. Note:algs use IALG_EXTERNAL_SHM, which is IALG_ESDATA.
[processor-sdk/performance-audio-sr.git] / processor_audio_sdk_1_00_00_00 / pasdk / common / paf_alg_malloc.c
index 463cd9d2477224640870f4630c8e9d195e956b4c..b613bf75109e38f285acc8e6ca1dc0037e409392 100644 (file)
@@ -207,6 +207,7 @@ PAF_ALG_allocMemory_ (
                             gPafHeapIdInt1,     (HeapMem_Handle)pafHeapMgr_readHeapHandle(gPafHeapIdInt1),
                             gPafHeapIdExt,      (HeapMem_Handle)pafHeapMgr_readHeapHandle(gPafHeapIdExt),
                             gPafHeapIdInt1Shm,  (HeapMem_Handle)pafHeapMgr_readHeapHandle(gPafHeapIdInt1Shm),
+                            gPafHeapIdExtShm,   (HeapMem_Handle)pafHeapMgr_readHeapHandle(gPafHeapIdExtShm),
                             0);
                     TRACE_GEN((&TR_MOD, "PAF_ALG_allocMemory_.%d: alloc %d bytes from space %d", __LINE__, memTab[i].size, memTab[i].space));
                     //if(!(memTab[i].base=(void *)MEM_alloc(
@@ -401,20 +402,20 @@ PAF_ALG_memSpaceToHeapId_ (
 {
     switch(space)
     {
-        case IALG_SARAM:    /* IALG_SARAM0 = IALG_SARAM :  Normally used for IRAM.  */
+        case IALG_SARAM:    /* IALG_SARAM0 = IALG_SARAM :  Normally used for IRAM */ // FL: K2G: used for L2 on DSP
             TRACE_GEN((&TR_MOD, "PAF_ALG_memSpaceToHeapId_.%d: IALG_SARAM (0x%x) 0x%x", __LINE__, space, p->iHeapId));
             return p->iHeapId;
 
-        case IALG_EXTERNAL: // normally external SDRAM
+        case IALG_EXTERNAL: // normally external SDRAM // FL: K2G: used for DDR local memory
             TRACE_GEN((&TR_MOD, "PAF_ALG_memSpaceToHeapId_.%d: IALG_EXTERNAL (0x%x) 0x%x", __LINE__, space, p->eHeapId));
             return p->eHeapId;
 
-        case IALG_SARAM1:
+        case IALG_SARAM1: // FL: K2G: used for MSMC local memory
             TRACE_GEN((&TR_MOD, "PAF_ALG_memSpaceToHeapId_.%d: IALG_SARAM1 (0x%x) 0x%x", __LINE__, space, p->lHeapId));
             return p->lHeapId;
 
-        case IALG_SARAM2:
-            TRACE_GEN((&TR_MOD, "PAF_ALG_memSpaceToHeapId_.%d: IALG_SARAM2 (0x%x) 0x%x", __LINE__, space, p->lHeapIdShm));
+        case IALG_SARAM2:  // FL: K2G: used for MSMC shared memory
+            TRACE_GEN((&TR_MOD, "PAF_ALG_memSpaceToHeapId_.%d: IALG_SARAM2 (IALG_SARAM_SHM) (0x%x) 0x%x", __LINE__, space, p->lHeapIdShm));
             return p->lHeapIdShm;
 
         case IALG_DARAM0:   // Can't use this because it is zero and overridden
@@ -429,9 +430,9 @@ PAF_ALG_memSpaceToHeapId_ (
             TRACE_GEN((&TR_MOD, "PAF_ALG_memSpaceToHeapId_.%d: IALG_DARAM2 (0x%x) 0x%x", __LINE__, space, p->iHeapId));
             return p->iHeapId;    // not normally used.
 
-        case IALG_ESDATA:   // not normally used.
-            TRACE_GEN((&TR_MOD, "PAF_ALG_memSpaceToHeapId_.%d: IALG_ESDATA (0x%x) 0x%x", __LINE__, space, p->eHeapId));
-            return p->eHeapId;
+        case IALG_ESDATA:   // FL: K2G: used for DDR shared memory
+            TRACE_GEN((&TR_MOD, "PAF_ALG_memSpaceToHeapId_.%d: IALG_ESDATA (IALG_EXTERNAL_SHM) (0x%x) 0x%x", __LINE__, space, p->eHeapIdShm));
+            return p->eHeapIdShm;
 
         default:
             TRACE_GEN((&TR_MOD, "PAF_ALG_memSpaceToHeapId_.%d: default (0x%x) 0x%x", __LINE__, space, p->eHeapId));
@@ -447,20 +448,20 @@ PAF_ALG_memSpaceToHeap_ (
 {
     switch(space)
     {
-        case IALG_SARAM:    /* IALG_SARAM0 = IALG_SARAM :  Normally used for IRAM.  */
+        case IALG_SARAM:    /* IALG_SARAM0 = IALG_SARAM :  Normally used for IRAM. */ // FL: K2G: used for L2 on DSP
             TRACE_GEN((&TR_MOD, "PAF_ALG_memSpaceToHeap_.%d: IALG_SARAM (0x%x) 0x%x", __LINE__, space, p->iHeapId));
             return p->hIHeap;
 
-        case IALG_EXTERNAL: // normally external SDRAM
+        case IALG_EXTERNAL: // normally external SDRAM // FL: K2G: used for DDR local memory
             TRACE_GEN((&TR_MOD, "PAF_ALG_memSpaceToHeap_.%d: IALG_EXTERNAL (0x%x) 0x%x", __LINE__, space, p->eHeapId));
             return p->hEHeap;
 
-        case IALG_SARAM1:   // Used by Dolby Digital
+        case IALG_SARAM1:   // FL: K2G: used for MSMC local memory
             TRACE_GEN((&TR_MOD, "PAF_ALG_memSpaceToHeap_.%d: IALG_SARAM1 (0x%x) 0x%x", __LINE__, space, p->lHeapId));
             return p->hLHeap;
 
         case IALG_SARAM2:
-            TRACE_GEN((&TR_MOD, "PAF_ALG_memSpaceToHeap_.%d: IALG_SARAM2 (0x%x) 0x%x", __LINE__, space, p->iHeapId));
+            TRACE_GEN((&TR_MOD, "PAF_ALG_memSpaceToHeap_.%d: IALG_SARAM2 (IALG_SARAM_SHM) (0x%x) 0x%x", __LINE__, space, p->lHeapIdShm));
             return p->hLHeapShm;
 
         case IALG_DARAM0:   // Can't use this because it is zero and overridden
@@ -475,9 +476,9 @@ PAF_ALG_memSpaceToHeap_ (
             TRACE_GEN((&TR_MOD, "PAF_ALG_memSpaceToHeap_.%d: IALG_DARAM2 (0x%x) 0x%x", __LINE__, space, p->iHeapId));
             return p->hIHeap;    // not normally used.
 
-        case IALG_ESDATA:   // not normally used.
-            TRACE_GEN((&TR_MOD, "PAF_ALG_memSpaceToHeap_.%d: IALG_ESDATA (0x%x) 0x%x", __LINE__, space, p->eHeapId));
-            return p->hEHeap;
+        case IALG_ESDATA:   // FL: K2G: used for DDR shared memory
+            TRACE_GEN((&TR_MOD, "PAF_ALG_memSpaceToHeap_.%d: IALG_ESDATA (0x%x) 0x%x", __LINE__, space, p->eHeapIdShm));
+            return p->hEHeapShm;
 
         default:
             TRACE_GEN((&TR_MOD, "PAF_ALG_memSpaceToHeap_.%d: default (0x%x) 0x%x", __LINE__, space, p->eHeapId));
@@ -504,6 +505,8 @@ PAF_ALG_setup_ (
     HeapMem_Handle hEHeap,
     Int lHeapIdShm,
     HeapMem_Handle hLHeapShm,
+    Int eHeapIdShm,
+    HeapMem_Handle hEHeapShm,
     Int clr
 )
 { 
@@ -516,12 +519,14 @@ PAF_ALG_setup_ (
     p->lHeapId      = lHeapId;
     p->eHeapId      = eHeapId;
     p->lHeapIdShm   = lHeapIdShm;
+    p->eHeapIdShm   = eHeapIdShm;
     
     /* initialize heap handles */
     p->hIHeap       = hIHeap;
     p->hLHeap       = hLHeap;
     p->hEHeap       = hEHeap;
     p->hLHeapShm    = hLHeapShm;
+    p->hEHeapShm    = hEHeapShm;
     
     /* initialize clear flag */
     p->clr=clr;