/**
 * @file hv_drv_OsdFont.c
 * @brief Osd Driver common c file.
 * @details This file provides the following functions: \n
 *          (1) resource size getter functions \n
 *          (5) all kinds of string getter 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"

const CHAR8* Hv_Drv_OsdCommon_GetPixelFormatStr(OsdPixelFormat enFormat)
{
    static const CHAR8 * const s_apPixelFormatStrings[] =
            {"RGBA8888", "RGBA4444", "RGB565", "A8", "A4", "RGB888"};
    return s_apPixelFormatStrings[enFormat];
}

const CHAR8 *Hv_Drv_OsdCommon_GetTextAlignTypeStr(UCHAR8 ucAlignType)
{
    static const CHAR8 * const s_apAlignStrings[] =
            {"Left-Aligned", "Center-Aligned", "Right-Aligned"};

    return s_apAlignStrings[ucAlignType];
}

const CHAR8 *Hv_Drv_OsdCommon_GetResourceSizeStr(OsdResourceSize enSize)
{
    UCHAR8 ucWidth = 0;
    UCHAR8 ucHeight = 0;
    static CHAR8 s_acUserDefinedString[8];

    Hv_Drv_OsdResource_GetSize(enSize, &ucWidth, &ucHeight);

    HV_SPRINTF(s_acUserDefinedString, "%dX%d", ucWidth, ucHeight);
    return s_acUserDefinedString;
}

const CHAR8 *Hv_Drv_OsdCommon_GetResourceTypeStr(OsdResourceType enType)
{
    static const CHAR8 * const s_apResourceTypeStrings[] = {"1bit", "2bit", "4bit", "6bit", "8bit"};

    return s_apResourceTypeStrings[enType];
}

const CHAR8 *Hv_Drv_OsdCommon_GetSRAMChangeTypeStr(OsdSRAMChangeType enType)
{
    static const CHAR8 * const s_apSRAMChangeTypeStrings[] = {"None", "Partial", "Full"};

    return s_apSRAMChangeTypeStrings[enType];
}

const CHAR8 *Hv_Drv_OsdCommon_GetBlendingStageStr(OsdBlendingStage enStage)
{
    static const CHAR8 * const s_apBlendingStageStrings[] = {
            "rectgroup", "rectgroup-font", "win01", "win23", "win0123",
            "winrect", "winall", "winall-graphic", "hsblend"
    };

    return s_apBlendingStageStrings[enStage];
}

USHORT16 Hv_Drv_OsdCommon_GetResourceBytes(OsdResourceSize enSize, OsdResourceType enType)
{
    UCHAR8 ucWidth = 0;
    UCHAR8 ucHeight = 0;
    UCHAR8 ucBits = 0;
    USHORT16 usBytes = 0;

    Hv_Drv_OsdResource_GetSize(enSize, &ucWidth, &ucHeight);

    ucBits = Hv_Drv_OsdResource_GetBits(enType);
    usBytes = ((USHORT16)ucWidth * ucHeight * ucBits) >> 3;

    return usBytes;
}

UCHAR8 Hv_Drv_OsdCommon_GetPixelBits(OsdPixelFormat enFormat)
{
    return Hv_Cal_Osd_GetPixelBits(enFormat);
}
