/**
 * @file hv_drv_OsdMemory.c
 * @brief Osd Driver Memory management c file.
 * @details This file provides the following functions: \n
 *          (4) memory init functions \n
 *          (5) memory change record functions \n
 *
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2022-08-31
 * @copyright Copyright(c),2022-8, Hiview Software. All rights reserved.
 * @par History:
 * <table>
 * <tr><th>Author         <th>Date        <th>Change Description
 * <tr><td>OSD Group      <td>2022-08-31   <td>create
 * </table>
*/

#include "hv_drv_Osd.h"

UINT32 g_uiOsdDriverDDRPos = 0;
UINT32 g_uiOsdDriverDDRPosReserved = 0;

VOID Hv_Drv_OsdMemory_SetSRAMChange(OsdSRAMChange *pstChange, OsdSRAMChangeType enType,
                                UINT32 uiChangeStart, UINT32 uiChangeEnd)
{
    if (OSD_SRAM_CHANGE_FULL == enType || OSD_SRAM_CHANGE_NONE == enType)
    {
        pstChange->enType = enType;
        return;
    }

    if (OSD_SRAM_CHANGE_FULL == pstChange->enType)
    {
        return;
    }

    uiChangeStart = round_down(uiChangeStart, 16);
    uiChangeEnd = roundup(uiChangeEnd, 16);

    if (OSD_SRAM_CHANGE_NONE == pstChange->enType)
    {
        pstChange->enType = OSD_SRAM_CHANGE_PARTIAL;
        pstChange->uiChangeStart = uiChangeStart;
        pstChange->uiChangeEnd = uiChangeEnd;
    }
    else
    {
        pstChange->uiChangeStart = min(uiChangeStart, pstChange->uiChangeStart);
        pstChange->uiChangeEnd = max(uiChangeEnd, pstChange->uiChangeEnd);
    }
}

VOID Hv_Drv_OsdMemory_Init(VOID)
{
    g_uiOsdDriverDDRPos = OSD_DRIVER_DDR_START;
}
