Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a3c4ada7 authored by Andy Hung's avatar Andy Hung Committed by Automerger Merge Worker
Browse files

Merge "libeffects : Remove InstAlloc wrapper support" am: 676ad0ec am: 64437b08

Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/1620875

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I15b00cfc48abb55baa2e9e18ff6f55f4d5894d95
parents 392ec7ae 64437b08
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -59,7 +59,6 @@ cc_library_static {
        "Eq/src/LVEQNB_Init.cpp",
        "Eq/src/LVEQNB_Process.cpp",
        "Eq/src/LVEQNB_Tables.cpp",
        "Common/src/InstAlloc.cpp",
        "Common/src/DC_2I_D16_TRC_WRA_01.cpp",
        "Common/src/DC_2I_D16_TRC_WRA_01_Init.cpp",
        "Common/src/Copy_16.cpp",
@@ -146,11 +145,9 @@ cc_library_static {
        "Reverb/src/LVREV_ClearAudioBuffers.cpp",
        "Reverb/src/LVREV_GetControlParameters.cpp",
        "Reverb/src/LVREV_GetInstanceHandle.cpp",
        "Reverb/src/LVREV_GetMemoryTable.cpp",
        "Reverb/src/LVREV_Process.cpp",
        "Reverb/src/LVREV_SetControlParameters.cpp",
        "Reverb/src/LVREV_Tables.cpp",
        "Common/src/InstAlloc.cpp",
        "Common/src/LoadConst_32.cpp",
        "Common/src/From2iToMono_32.cpp",
        "Common/src/Mult3s_32x16.cpp",
+0 −1
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@
#include "LVM_Private.h"
#include "LVM_Tables.h"
#include "VectorArithmetic.h"
#include "InstAlloc.h"

/****************************************************************************************/
/*                                                                                      */
+0 −76
Original line number Diff line number Diff line
/*
 * Copyright (C) 2004-2010 NXP Software
 * Copyright (C) 2010 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __INSTALLOC_H__
#define __INSTALLOC_H__

#include "LVM_Types.h"
/*######################################################################################*/
/*  Type declarations                                                                   */
/*######################################################################################*/
typedef struct {
    LVM_UINT32 TotalSize;  /*  Accumulative total memory size                      */
    uintptr_t pNextMember; /*  Pointer to the next instance member to be allocated */
} INST_ALLOC;

/*######################################################################################*/
/*  Function prototypes                                                          */
/*######################################################################################*/

/****************************************************************************************
 *  Name        : InstAlloc_Init()
 *  Input       : pms  - Pointer to the INST_ALLOC instance
                  StartAddr - Base address of the instance memory
 *  Returns     : Error code
 *  Description : Initializes the instance distribution and memory size calculation function
 *  Remarks     :
 ****************************************************************************************/

void InstAlloc_Init(INST_ALLOC* pms, void* StartAddr);

/****************************************************************************************
 *  Name        : InstAlloc_AddMember()
 *  Input       : pms  - Pointer to the INST_ALLOC instance
                  Size - The size in bytes of the new added member
 *  Returns     : A pointer to the new added member
 *  Description : Allocates space for a new member in the instance memory and returns
                  a pointer to this new member.  The start address of all members will
                  be 32 bit alligned.
 *  Remarks     :
 ****************************************************************************************/

void* InstAlloc_AddMember(INST_ALLOC* pms, LVM_UINT32 Size);

/****************************************************************************************
 *  Name        : InstAlloc_GetTotal()
 *  Input       : pms  - Pointer to the INST_ALLOC instance
 *  Returns     : The instance memory size
 *  Description : This functions returns the calculated instance memory size
 *  Remarks     :
 ****************************************************************************************/

LVM_UINT32 InstAlloc_GetTotal(INST_ALLOC* pms);

void* InstAlloc_AddMemberAllRet(INST_ALLOC* pms, LVM_UINT32 Size[], void** ptr);

void* InstAlloc_AddMemberAll(INST_ALLOC* pms, LVM_UINT32 Size[], LVM_MemoryTable_st* pMemoryTable);

void InstAlloc_InitAll(INST_ALLOC* pms, LVM_MemoryTable_st* pMemoryTable);

void InstAlloc_InitAll_NULL(INST_ALLOC* pms);

#endif /* __JBS_INSTALLOC_H__ */
+0 −21
Original line number Diff line number Diff line
@@ -134,27 +134,6 @@ static inline LVM_Fs_en lvmFsForSampleRate(int sampleRate) {
    return LVM_FS_INVALID;
}

/* Memory Types */
typedef enum {
    LVM_PERSISTENT_SLOW_DATA = LVM_MEMREGION_PERSISTENT_SLOW_DATA,
    LVM_PERSISTENT_FAST_DATA = LVM_MEMREGION_PERSISTENT_FAST_DATA,
    LVM_PERSISTENT_FAST_COEF = LVM_MEMREGION_PERSISTENT_FAST_COEF,
    LVM_TEMPORARY_FAST = LVM_MEMREGION_TEMPORARY_FAST,
    LVM_MEMORYTYPE_DUMMY = LVM_MAXENUM
} LVM_MemoryTypes_en;

/* Memory region definition */
typedef struct {
    LVM_UINT32 Size;         /* Region size in bytes */
    LVM_MemoryTypes_en Type; /* Region type */
    void* pBaseAddress;      /* Pointer to the region base address */
} LVM_MemoryRegion_st;

/* Memory table containing the region definitions */
typedef struct {
    LVM_MemoryRegion_st Region[LVM_NR_MEMORY_REGIONS]; /* One definition for each region */
} LVM_MemoryTable_st;

/****************************************************************************************/
/*                                                                                      */
/*  Standard Function Prototypes                                                        */
+0 −164
Original line number Diff line number Diff line
/*
 * Copyright (C) 2004-2010 NXP Software
 * Copyright (C) 2010 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "InstAlloc.h"

/****************************************************************************************
 *  Name        : InstAlloc_Init()
 *  Input       : pms  - Pointer to the INST_ALLOC instance
                  StartAddr - Base address of the instance memory
 *  Returns     : Error code
 *  Description : Initializes the instance distribution and memory size calculation function
 *  Remarks     :
 ****************************************************************************************/

void InstAlloc_Init(INST_ALLOC* pms, void* StartAddr) {
    pms->TotalSize = 3;
    pms->pNextMember = (((uintptr_t)StartAddr + 3) & (uintptr_t)~3);
}

/****************************************************************************************
 *  Name        : InstAlloc_AddMember()
 *  Input       : pms  - Pointer to the INST_ALLOC instance
                  Size - The size in bytes of the new added member
 *  Returns     : A pointer to the new added member
 *  Description : Allocates space for a new member in the instance memory and returns
                  a pointer to this new member.  The start address of all members will
                  be 32 bit alligned.
 *  Remarks     :
 ****************************************************************************************/

void* InstAlloc_AddMember(INST_ALLOC* pms, LVM_UINT32 Size) {
    void* NewMemberAddress; /* Variable to temporarily store the return value */
    NewMemberAddress = (void*)pms->pNextMember;

    Size = ((Size + 3) & (LVM_UINT32)~3); /* Ceil the size to a multiple of four */

    pms->TotalSize += Size;
    pms->pNextMember += Size;

    return (NewMemberAddress);
}

/****************************************************************************************
 *  Name        : InstAlloc_GetTotal()
 *  Input       : pms  - Pointer to the INST_ALLOC instance
 *  Returns     : The instance memory size
 *  Description : This functions returns the calculated instance memory size
 *  Remarks     :
 ****************************************************************************************/

LVM_UINT32 InstAlloc_GetTotal(INST_ALLOC* pms) {
    if (pms->TotalSize > 3) {
        return (pms->TotalSize);
    } else {
        return 0; /* No memory added */
    }
}

void InstAlloc_InitAll(INST_ALLOC* pms, LVM_MemoryTable_st* pMemoryTable) {
    uintptr_t StartAddr;

    StartAddr = (uintptr_t)pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].pBaseAddress;

    pms[0].TotalSize = 3;
    pms[0].pNextMember = ((StartAddr + 3) & (uintptr_t)~3);

    StartAddr = (uintptr_t)pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].pBaseAddress;

    pms[1].TotalSize = 3;
    pms[1].pNextMember = ((StartAddr + 3) & (uintptr_t)~3);

    StartAddr = (uintptr_t)pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].pBaseAddress;

    pms[2].TotalSize = 3;
    pms[2].pNextMember = ((StartAddr + 3) & (uintptr_t)~3);

    StartAddr = (uintptr_t)pMemoryTable->Region[LVM_TEMPORARY_FAST].pBaseAddress;

    pms[3].TotalSize = 3;
    pms[3].pNextMember = ((StartAddr + 3) & (uintptr_t)~3);
}

/****************************************************************************************
 *  Name        : InstAlloc_InitAll_NULL()
 *  Input       : pms  - Pointer to array of four INST_ALLOC instances
 *  Returns     : Nothing
 *  Description : This function reserves Size of 3 bytes for all memory regions and
 *                intializes pNextMember for all regions to 0
 *  Remarks     :
 ****************************************************************************************/

void InstAlloc_InitAll_NULL(INST_ALLOC* pms) {
    pms[0].TotalSize = 3;
    pms[0].pNextMember = 0;

    pms[1].TotalSize = 3;
    pms[1].pNextMember = 0;

    pms[2].TotalSize = 3;
    pms[2].pNextMember = 0;

    pms[3].TotalSize = 3;
    pms[3].pNextMember = 0;
}

void* InstAlloc_AddMemberAll(INST_ALLOC* pms, LVM_UINT32 Size[], LVM_MemoryTable_st* pMemoryTable) {
    void* NewMemberAddress; /* Variable to temporarily store the return value */

    /* coverity[returned_pointer] Ignore coverity warning that ptr is not used */
    NewMemberAddress =
            InstAlloc_AddMember(&pms[LVM_PERSISTENT_SLOW_DATA], Size[LVM_PERSISTENT_SLOW_DATA]);

    pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].Size =
            InstAlloc_GetTotal(&pms[LVM_PERSISTENT_SLOW_DATA]);
    pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].Type = LVM_PERSISTENT_SLOW_DATA;
    pMemoryTable->Region[LVM_PERSISTENT_SLOW_DATA].pBaseAddress = LVM_NULL;

    NewMemberAddress =
            InstAlloc_AddMember(&pms[LVM_PERSISTENT_FAST_DATA], Size[LVM_PERSISTENT_FAST_DATA]);

    pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].Size =
            InstAlloc_GetTotal(&pms[LVM_PERSISTENT_FAST_DATA]);
    pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].Type = LVM_PERSISTENT_FAST_DATA;
    pMemoryTable->Region[LVM_PERSISTENT_FAST_DATA].pBaseAddress = LVM_NULL;

    NewMemberAddress =
            InstAlloc_AddMember(&pms[LVM_PERSISTENT_FAST_COEF], Size[LVM_PERSISTENT_FAST_COEF]);

    pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].Size =
            InstAlloc_GetTotal(&pms[LVM_PERSISTENT_FAST_COEF]);
    pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].Type = LVM_PERSISTENT_FAST_COEF;
    pMemoryTable->Region[LVM_PERSISTENT_FAST_COEF].pBaseAddress = LVM_NULL;

    NewMemberAddress = InstAlloc_AddMember(&pms[LVM_TEMPORARY_FAST], Size[LVM_TEMPORARY_FAST]);

    pMemoryTable->Region[LVM_TEMPORARY_FAST].Size = InstAlloc_GetTotal(&pms[LVM_TEMPORARY_FAST]);
    pMemoryTable->Region[LVM_TEMPORARY_FAST].Type = LVM_TEMPORARY_FAST;
    pMemoryTable->Region[LVM_TEMPORARY_FAST].pBaseAddress = LVM_NULL;

    return (NewMemberAddress);
}

void* InstAlloc_AddMemberAllRet(INST_ALLOC* pms, LVM_UINT32 Size[], void** ptr) {
    ptr[0] = InstAlloc_AddMember(&pms[LVM_PERSISTENT_SLOW_DATA], Size[LVM_PERSISTENT_SLOW_DATA]);
    ptr[1] = InstAlloc_AddMember(&pms[LVM_PERSISTENT_FAST_DATA], Size[LVM_PERSISTENT_FAST_DATA]);
    ptr[2] = InstAlloc_AddMember(&pms[LVM_PERSISTENT_FAST_COEF], Size[LVM_PERSISTENT_FAST_COEF]);
    ptr[3] = InstAlloc_AddMember(&pms[LVM_TEMPORARY_FAST], Size[LVM_TEMPORARY_FAST]);

    return (ptr[0]);
}
Loading