/**
 * @brief           VID Primitive
 * @author          AXELL CORPORATION
 * @description     VID Primitive Layer.
 * @note            none
 * @history         2017_02_22  初版
 * @history         2017_10_26  Ver2.0
*/
/* DOM-IGNORE-BEGIN */
/*
 * This program was created by AXELL CORPORATION.
 * Copyright (C) 2017 AXELL CORPORATION, all rights reserved.
 */
/* DOM-IGNORE-END */

#include <stdio.h>
#include "vid/vidprm.h"
#include "register/AG903_vidreg.h"
#include "AG903_common.h"


/**
 * @brief         VIDCTRL レジスタ設定
 * @param         on [in] ONフィールド設定値
 * @return        void
 * @description   VIDCTRL レジスタ設定
*/
void AG903_VidPrmSetVIDCTRL(uint32_t on)
{
    uint32_t                    val;

    ASSERT(!(on & ~(0x1)));

    val = (on << AG903_VID_CTRL_ON_POS);

    AG903_VID->CTRL = val;
}


/**
 * @brief         VIDCTRL レジスタ取得
 * @param         on [out] ONフィールド取得値
 * @return        void
 * @description   VIDCTRL レジスタ取得
*/
void AG903_VidPrmGetVIDCTRL(uint32_t *on)
{
    uint32_t                    val;

    ASSERT(on != NULL);

    val = AG903_VID->CTRL;

    *on = (val & AG903_VID_CTRL_ON_MSK) >> AG903_VID_CTRL_ON_POS;
}


/**
 * @brief         VIDFMTレジスタ 設定
 * @param         fmt [in] FMTフィールド設定値
 * @return        void
 * @description   VIDFMTレジスタ 設定
*/
void AG903_VidPrmSetVIDFMT(uint32_t fmt)
{
    uint32_t                    val;

    ASSERT(!(fmt & ~(0x7)));

    val = (fmt << AG903_VID_FMT_FMT_POS);

    AG903_VID->FMT = val;
}


/**
 * @brief         VIDFMT レジスタ取得
 * @param         fmt [out] FMTフィールド取得値
 * @return        void
 * @description   VIDFMT レジスタ取得
*/
void AG903_VidPrmGetVIDFMT(uint32_t *fmt)
{
    uint32_t                    val;

    ASSERT(fmt != NULL);

    val = AG903_VID->FMT;

    *fmt = (val & AG903_VID_FMT_FMT_MSK) >> AG903_VID_FMT_FMT_POS;
}


/**
 * @brief         VIDIOnCTRL レジスタ設定
 * @param         id [in] チャンネル番号 
 * @param         soe [in] SOEフィールド設定値 
 * @return        void
 * @description   VIDIOnCTRL レジスタ設定
*/
void AG903_VidPrmSetVIDIOnCTRL(uint32_t id, uint32_t soe)
{
    uint32_t                    val;

    ASSERT(id < AG903_VID_PRM_MAX_IO_PORTS);
    ASSERT(!(soe & ~(0x1)));

    val = (soe << AG903_VIDIOn_CTRL_SOE_POS);

    AG903_VIDIOn(id)->CTRL = val;
}


/**
 * @brief         VIDIOnCTRL レジスタ取得
 * @param         id [in] チャンネル番号 
 * @param         soe [out] SOEフィールド取得値  
 * @return        void
 * @description   VIDIOnCTRL レジスタ取得
*/
void AG903_VidPrmGetVIDIOnCTRL(uint32_t id, uint32_t *soe)
{
    uint32_t                    val;

    ASSERT(id < AG903_VID_PRM_MAX_IO_PORTS);
    ASSERT(soe != NULL);

    val = AG903_VIDIOn(id)->CTRL;

    *soe = (val & AG903_VIDIOn_CTRL_SOE_MSK) >> AG903_VIDIOn_CTRL_SOE_POS;
}


/**
 * @brief         VIDIOnMOD レジスタ設定
 * @param         id [in] チャンネル番号 
 * @param         mod [in] VIDIOnMOD設定値格納先
 * @return        void
 * @description   VIDIOnMOD レジスタ設定
*/
void AG903_VidPrmSetVIDIOnMOD(uint32_t id, VIDPrmParamVIDIOnMOD *mod)
{
    uint32_t                    val;

    ASSERT(id < AG903_VID_PRM_MAX_IO_PORTS);
    ASSERT(mod != NULL);
    ASSERT(!(mod->vpol & ~(0x1)));
    ASSERT(!(mod->hpol & ~(0x1)));
    ASSERT(!(mod->dpol & ~(0x1)));
    ASSERT(!(mod->fpol & ~(0x1)));
    ASSERT(!(mod->cpol & ~(0x1)));

    val = (mod->vpol << AG903_VIDIOn_MOD_VPOL_POS)
        | (mod->hpol << AG903_VIDIOn_MOD_HPOL_POS)
        | (mod->dpol << AG903_VIDIOn_MOD_DPOL_POS)
        | (mod->fpol << AG903_VIDIOn_MOD_FPOL_POS)
        | (mod->cpol << AG903_VIDIOn_MOD_CPOL_POS);

    AG903_VIDIOn(id)->MOD = val;
}


/**
 * @brief         VIDIOnMOD レジスタ取得
 * @param         id [in] チャンネル番号 
 * @param         mod [out] VIDIOnMOD取得値格納先
 * @return        void
 * @description   VIDIOnMOD レジスタ取得
*/
void AG903_VidPrmGetVIDIOnMOD(uint32_t id, VIDPrmParamVIDIOnMOD *mod)
{
    uint32_t                    val;

    ASSERT(id < AG903_VID_PRM_MAX_IO_PORTS);
    ASSERT(mod != NULL);

    val = AG903_VIDIOn(id)->MOD;

    mod->vpol = (val & AG903_VIDIOn_MOD_VPOL_MSK) >> AG903_VIDIOn_MOD_VPOL_POS;
    mod->hpol = (val & AG903_VIDIOn_MOD_HPOL_MSK) >> AG903_VIDIOn_MOD_HPOL_POS;
    mod->dpol = (val & AG903_VIDIOn_MOD_DPOL_MSK) >> AG903_VIDIOn_MOD_DPOL_POS;
    mod->fpol = (val & AG903_VIDIOn_MOD_FPOL_MSK) >> AG903_VIDIOn_MOD_FPOL_POS;
    mod->cpol = (val & AG903_VIDIOn_MOD_CPOL_MSK) >> AG903_VIDIOn_MOD_CPOL_POS;
}


/**
 * @brief         VIDIOnOHPRM0 レジスタ設定
 * @param         id [in] チャンネル番号 
 * @param         hpw [in] HPWフィールド設定値 
 * @return        void
 * @description   VIDIOnOHPRM0 レジスタ設定
*/
void AG903_VidPrmSetVIDIOnOHPRM0(uint32_t id, uint32_t hpw)
{
    uint32_t                    val;

    ASSERT(id < AG903_VID_PRM_MAX_IO_PORTS);
    ASSERT(!(hpw & ~(0xFFF)));

    val = (hpw << AG903_VIDIOn_OHPRM0_HPW_POS);

    AG903_VIDIOn(id)->OHPRM0 = val;
}


/**
 * @brief         VIDIOnOHPRM0 レジスタ取得
 * @param         id [in] チャンネル番号 
 * @param         hpw [out] HPWフィールド取得値 
 * @return        void
 * @description   VIDIOnOHPRM0 レジスタ取得
*/
void AG903_VidPrmGetVIDIOnOHPRM0(uint32_t id, uint32_t *hpw)
{
    uint32_t                    val;

    ASSERT(id < AG903_VID_PRM_MAX_IO_PORTS);
    ASSERT(hpw != NULL);

    val = AG903_VIDIOn(id)->OHPRM0;

    *hpw = (val & AG903_VIDIOn_OHPRM0_HPW_MSK) >> AG903_VIDIOn_OHPRM0_HPW_POS;
}


/**
 * @brief         VIDIOnOHPRM1 レジスタ設定
 * @param         id [in] チャンネル番号 
 * @param         hfp [in] HFPフィールド設定値
 * @param         hbp [in] HBPフィールド設定値
 * @return        void
 * @description   VIDIOnOHPRM1 レジスタ設定
*/
void AG903_VidPrmSetVIDIOnOHPRM1(uint32_t id, uint32_t hfp, uint32_t hbp)
{
    uint32_t                    val;

    ASSERT(id < AG903_VID_PRM_MAX_IO_PORTS);
    ASSERT(!(hfp & ~(0xFFF)));
    ASSERT(!(hbp & ~(0xFFF)));

    val = (hfp << AG903_VIDIOn_OHPRM1_HFP_POS)
        | (hbp << AG903_VIDIOn_OHPRM1_HBP_POS);

    AG903_VIDIOn(id)->OHPRM1 = val;
}


/**
 * @brief         VIDIOnOHPRM1 ジスタ取得
 * @param         id [in] チャンネル番号 
 * @param         hfp [out] HFPフィールド取得値
 * @param         hbp [out] HBPフィールド取得値
 * @return        void
 * @description   VIDIOnOHPRM1 ジスタ取得
*/
void AG903_VidPrmGetVIDIOnOHPRM1(uint32_t id, uint32_t *hfp, uint32_t *hbp)
{
    uint32_t                    val;

    ASSERT(id < AG903_VID_PRM_MAX_IO_PORTS);
    ASSERT(hfp != NULL);
    ASSERT(hbp != NULL);

    val = AG903_VIDIOn(id)->OHPRM1;

    *hfp = (val & AG903_VIDIOn_OHPRM1_HFP_MSK) >> AG903_VIDIOn_OHPRM1_HFP_POS;
    *hbp = (val & AG903_VIDIOn_OHPRM1_HBP_MSK) >> AG903_VIDIOn_OHPRM1_HBP_POS;
}


/**
 * @brief         VIDIOnOVPRM0 レジスタ設定
 * @param         id [in] チャンネル番号 
 * @param         vpw [in] VPWフィールド設定値
 * @return        void
 * @description   VIDIOnOVPRM0 レジスタ設定
*/
void AG903_VidPrmSetVIDIOnOVPRM0(uint32_t id, uint32_t vpw)
{
    uint32_t                    val;

    ASSERT(id < AG903_VID_PRM_MAX_IO_PORTS);
    ASSERT(!(vpw & ~(0xFFF)));

    val = (vpw << AG903_VIDIOn_OVPRM0_VPW_POS);

    AG903_VIDIOn(id)->OVPRM0 = val;
}


/**
 * @brief         VIDIOnOVPRM0 レジスタ取得
 * @param         id [in] チャンネル番号 
 * @param         vpw [out] VPWフィールド取得値 
 * @return        void
 * @description   VIDIOnOVPRM0 レジスタ取得
*/
void AG903_VidPrmGetVIDIOnOVPRM0(uint32_t id, uint32_t *vpw)
{
    uint32_t                    val;

    ASSERT(id < AG903_VID_PRM_MAX_IO_PORTS);
    ASSERT(vpw != NULL);

    val = AG903_VIDIOn(id)->OVPRM0;

    *vpw = (val & AG903_VIDIOn_OVPRM0_VPW_MSK) >> AG903_VIDIOn_OVPRM0_VPW_POS;
}


/**
 * @brief         VIDIOnOVPRM1 レジスタ設定
 * @param         id [in] チャンネル番号 
 * @param         vfp [in] VFPフィールド設定値 
 * @param         vbp [in] VBPフィールド設定値 
 * @return        void
 * @description   VIDIOnOVPRM1 レジスタ設定
*/
void AG903_VidPrmSetVIDIOnOVPRM1(uint32_t id, uint32_t vfp, uint32_t vbp)
{
    uint32_t                    val;

    ASSERT(id < AG903_VID_PRM_MAX_IO_PORTS);
    ASSERT(!(vfp & ~(0xFFF)));
    ASSERT(!(vbp & ~(0xFFF)));

    val = (vfp << AG903_VIDIOn_OVPRM1_VFP_POS)
        | (vbp << AG903_VIDIOn_OVPRM1_VBP_POS);

    AG903_VIDIOn(id)->OVPRM1 = val;
}


/**
 * @brief         VIDIOnOVPRM1 レジスタ取得
 * @param         id [in] チャンネル番号 
 * @param         vfp [out] VFPフィールド取得値
 * @param         vbp [out] VBPフィールド取得値 
 * @return        void
 * @description   VIDIOnOVPRM1 レジスタ取得
*/
void AG903_VidPrmGetVIDIOnOVPRM1(uint32_t id, uint32_t *vfp, uint32_t *vbp)
{
    uint32_t                    val;

    ASSERT(id < AG903_VID_PRM_MAX_IO_PORTS);
    ASSERT(vfp != NULL);
    ASSERT(vbp != NULL);

    val = AG903_VIDIOn(id)->OVPRM1;

    *vfp = (val & AG903_VIDIOn_OVPRM1_VFP_MSK) >> AG903_VIDIOn_OVPRM1_VFP_POS;
    *vbp = (val & AG903_VIDIOn_OVPRM1_VBP_MSK) >> AG903_VIDIOn_OVPRM1_VBP_POS;
}


/**
 * @brief         VIDIOnOSIZE レジスタ設定
 * @param         id [in] チャンネル番号 
 * @param         vfs [in] VFSフィールド設定値
 * @param         hfs [in] HFSフィールド設定値 
 * @return        void
 * @description   VIDIOnOSIZE レジスタ設定
*/
void AG903_VidPrmSetVIDIOnOSIZE(uint32_t id, uint32_t vfs, uint32_t hfs)
{
    uint32_t                    val;

    ASSERT(id < AG903_VID_PRM_MAX_IO_PORTS);
    ASSERT(!(vfs & ~(0xFFF)));
    ASSERT(!(hfs & ~(0xFFF)));

    val = (vfs << AG903_VIDIOn_OSIZE_VFS_POS)
        | (hfs << AG903_VIDIOn_OSIZE_HFS_POS);

    AG903_VIDIOn(id)->OSIZE = val;
}


/**
 * @brief         VIDIOnOSIZE レジスタ取得
 * @param         id [in] チャンネル番号 
 * @param         vfs [out] VFSフィールド取得値
 * @param         hfs [out] HFSフィールド取得値 
 * @return        void
 * @description   VIDIOnOSIZE レジスタ取得
*/
void AG903_VidPrmGetVIDIOnOSIZE(uint32_t id, uint32_t *vfs, uint32_t *hfs)
{
    uint32_t                    val;

    ASSERT(id < AG903_VID_PRM_MAX_IO_PORTS);
    ASSERT(vfs != NULL);
    ASSERT(hfs != NULL);

    val = AG903_VIDIOn(id)->OSIZE;

    *vfs = (val & AG903_VIDIOn_OSIZE_VFS_MSK) >> AG903_VIDIOn_OSIZE_VFS_POS;
    *hfs = (val & AG903_VIDIOn_OSIZE_HFS_MSK) >> AG903_VIDIOn_OSIZE_HFS_POS;
}


/**
 * @brief         VIDIOnSTATE レジスタ取得
 * @param         id [in] チャンネル番号 
 * @param         cwt [out] CWTフィールド取得値 
 * @return        void
 * @description   VIDIOnSTATE レジスタ取得
*/
void AG903_VidPrmGetVIDIOnSTAT(uint32_t id, uint32_t *cwt)
{
    uint32_t                    val;

    ASSERT(id < AG903_VID_PRM_MAX_IO_PORTS);
    ASSERT(cwt != NULL);

    val = AG903_VIDIOn(id)->STAT;

    *cwt = (val & AG903_VIDIOn_STAT_CWT_MSK) >> AG903_VIDIOn_STAT_CWT_POS;
}


/**
 * @brief         VIDCOnMOD レジスタ設定
 * @param         id [in] チャンネル番号 
 * @param         mod [in] VIDCOnMOD設定値格納先
 * @return        void
 * @description   VIDCOnMOD レジスタ設定
*/
void AG903_VidPrmSetVIDCOnMOD(uint32_t id, VIDPrmParamVIDCOnMOD *mod)
{
    uint32_t                    val;

    ASSERT(id < AG903_VID_PRM_MAX_CAPTURE_PORTS);
    ASSERT(mod != NULL);
    ASSERT(!(mod->tdmblk & ~(0x1)));
    ASSERT(!(mod->tdmtrs & ~(0x1)));
    ASSERT(!(mod->delay & ~(0x1)));
    ASSERT(!(mod->trsdec & ~(0x1)));

    val = (mod->tdmblk << AG903_VIDCOn_MOD_TDMBLK_POS)
        | (mod->tdmtrs << AG903_VIDCOn_MOD_TDMTRS_POS)
        | (mod->delay  << AG903_VIDCOn_MOD_DELAY_POS)
        | (mod->trsdec << AG903_VIDCOn_MOD_TRSDEC_POS);

    AG903_VIDCOn(id)->MOD = val;
}


/**
 * @brief         VIDCOnMOD レジスタ取得
 * @param         id [in] チャンネル番号 
 * @param         mod [out] VIDCOnMOD取得値格納先
 * @return        void
 * @description   VIDCOnMOD レジスタ取得
*/
void AG903_VidPrmGetVIDCOnMOD(uint32_t id, VIDPrmParamVIDCOnMOD *mod)
{
    uint32_t                    val;

    ASSERT(id < AG903_VID_PRM_MAX_CAPTURE_PORTS);
    ASSERT(mod != NULL);

    val = AG903_VIDCOn(id)->MOD;

    mod->tdmblk = (val & AG903_VIDCOn_MOD_TDMBLK_MSK) >> AG903_VIDCOn_MOD_TDMBLK_POS;
    mod->tdmtrs = (val & AG903_VIDCOn_MOD_TDMTRS_MSK) >> AG903_VIDCOn_MOD_TDMTRS_POS;
    mod->delay  = (val & AG903_VIDCOn_MOD_DELAY_MSK)  >> AG903_VIDCOn_MOD_DELAY_POS;
    mod->trsdec = (val & AG903_VIDCOn_MOD_TRSDEC_MSK) >> AG903_VIDCOn_MOD_TRSDEC_POS;
}


/**
 * @brief         VIDCOnTRSPRM レジスタ設定
 * @param         id [in] チャンネル番号 
 * @param         trsprm [in] VIDCOnTRSPRM設定値格納先
 * @return        void
 * @description   VIDCOnTRSPRM レジスタ設定
*/
void AG903_VidPrmSetVIDCOnTRSPRM(uint32_t id, VIDPrmParamVIDCOnTRSPRM *trsprm)
{
    uint32_t                    val;

    ASSERT(id < AG903_VID_PRM_MAX_CAPTURE_PORTS);
    ASSERT(trsprm != NULL);
    ASSERT(!(trsprm->efp  & ~(0x1)));
    ASSERT(!(trsprm->ofp  & ~(0x1)));
    ASSERT(!(trsprm->vfp  & ~(0xFFF)));
    ASSERT(!(trsprm->href & ~(0x1)));
    ASSERT(!(trsprm->hfp  & ~(0xFFF)));

    val = (trsprm->efp  << AG903_VIDCOn_TRSPRM_EFP_POS)
        | (trsprm->ofp  << AG903_VIDCOn_TRSPRM_OFP_POS)
        | (trsprm->vfp  << AG903_VIDCOn_TRSPRM_VFP_POS)
        | (trsprm->href << AG903_VIDCOn_TRSPRM_HREF_POS)
        | (trsprm->hfp  << AG903_VIDCOn_TRSPRM_HFP_POS);

    AG903_VIDCOn(id)->TRSPRM = val;
}


/**
 * @brief         VIDCOnTRSPRM レジスタ取得
 * @param         id [in] チャンネル番号 
 * @param         trsprm [out] VIDCOnTRSPRM取得値格納先
 * @param         efp [out] EFPフィールド取得値 
 * @param         ofp [out] OFPフィールド取得値 
 * @param         vfp [out] VFPフィールド取得値 
 * @param         href [out] HREFフィールド取得値 
 * @param         hfp [out] HFPフィールド取得値 
 * @return        void
 * @description   VIDCOnTRSPRM レジスタ取得
*/
void AG903_VidPrmGetVIDCOnTRSPRM(uint32_t id, VIDPrmParamVIDCOnTRSPRM *trsprm)
{
    uint32_t                    val;

    ASSERT(id < AG903_VID_PRM_MAX_CAPTURE_PORTS);
    ASSERT(trsprm != NULL);

    val = AG903_VIDCOn(id)->TRSPRM;

    trsprm->efp  = (val & AG903_VIDCOn_TRSPRM_EFP_MSK)  >> AG903_VIDCOn_TRSPRM_EFP_POS;
    trsprm->ofp  = (val & AG903_VIDCOn_TRSPRM_OFP_MSK)  >> AG903_VIDCOn_TRSPRM_OFP_POS;
    trsprm->vfp  = (val & AG903_VIDCOn_TRSPRM_VFP_MSK)  >> AG903_VIDCOn_TRSPRM_VFP_POS;
    trsprm->href = (val & AG903_VIDCOn_TRSPRM_HREF_MSK) >> AG903_VIDCOn_TRSPRM_HREF_POS;
    trsprm->hfp  = (val & AG903_VIDCOn_TRSPRM_HFP_MSK)  >> AG903_VIDCOn_TRSPRM_HFP_POS;
}


/**
 * @brief         VIDCOnSDPRM レジスタ設定
 * @param         id [in] チャンネル番号 
 * @param         vmax [in] VMAXフィールド設定値 
 * @param         hmax [in] HMAXフィールド設定値 
 * @return        void
 * @description   VIDCOnSDPRM レジスタ設定
*/
void AG903_VidPrmSetVIDCOnSDPRM(uint32_t id, uint32_t vmax, uint32_t hmax)
{
    uint32_t                    val;

    ASSERT(id < AG903_VID_PRM_MAX_CAPTURE_PORTS);
    ASSERT(!(vmax & ~(0x1FFF)));
    ASSERT(!(hmax & ~(0x1FFF)));

    val = (vmax << AG903_VIDCOn_SDPRM_VMAX_POS)
        | (hmax << AG903_VIDCOn_SDPRM_HMAX_POS);

    AG903_VIDCOn(id)->SDPRM = val;
}


/**
 * @brief         VIDCOnSDPRM レジスタ取得
 * @param         id [in] チャンネル番号 
 * @param         vmax [out] VMAXフィールド取得値 
 * @param         hmax [out] HMAXフィールド取得値 
 * @return        void
 * @description   VIDCOnSDPRM レジスタ取得
*/
void AG903_VidPrmGetVIDCOnSDPRM(uint32_t id, uint32_t *vmax, uint32_t *hmax)
{
    uint32_t                    val;

    ASSERT(id < AG903_VID_PRM_MAX_CAPTURE_PORTS);
    ASSERT(vmax != NULL);
    ASSERT(hmax != NULL);

    val = AG903_VIDCOn(id)->SDPRM;

    *vmax = (val & AG903_VIDCOn_SDPRM_VMAX_MSK) >> AG903_VIDCOn_SDPRM_VMAX_POS;
    *hmax = (val & AG903_VIDCOn_SDPRM_HMAX_MSK) >> AG903_VIDCOn_SDPRM_HMAX_POS;
}


/**
 * @brief         VIDCOnSTAT レジスタ取得
 * @param         id [in] チャンネル番号 
 * @param         stat [out] VIDCOnSTAT取得値格納先
 * @return        void
 * @description   VIDCOnSTAT レジスタ取得
*/
void AG903_VidPrmGetVIDCOnSTAT(uint32_t id, VIDPrmParamVIDCOnSTAT *stat)
{
    uint32_t                    val;

    ASSERT(id < AG903_VID_PRM_MAX_CAPTURE_PORTS);
    ASSERT(stat != NULL);

    val = AG903_VIDCOn(id)->STAT;

    stat->blkval = (val & AG903_VIDCOn_STAT_BLKVAL_MSK) >> AG903_VIDCOn_STAT_BLKVAL_POS;
    stat->trsval = (val & AG903_VIDCOn_STAT_TRSVAL_MSK) >> AG903_VIDCOn_STAT_TRSVAL_POS;
    stat->vblank = (val & AG903_VIDCOn_STAT_VBLANK_MSK) >> AG903_VIDCOn_STAT_VBLANK_POS;
    stat->hblank = (val & AG903_VIDCOn_STAT_HBLANK_MSK) >> AG903_VIDCOn_STAT_HBLANK_POS;
    stat->tdmch  = (val & AG903_VIDCOn_STAT_TDMCH_MSK)  >> AG903_VIDCOn_STAT_TDMCH_POS;
}


/**
 * @brief         VIDCOnHST0 レジスタ取得
 * @param         id [in] チャンネル番号 
 * @param         hpw [out] HPWフィールド取得値 
 * @return        void
 * @description   VIDCOnHST0 レジスタ取得
*/
void AG903_VidPrmGetVIDCOnHST0(uint32_t id, uint32_t *hpw)
{
    uint32_t                    val;

    ASSERT(id < AG903_VID_PRM_MAX_CAPTURE_PORTS);
    ASSERT(hpw != NULL);

    val = AG903_VIDCOn(id)->HST0;

    *hpw = (val & AG903_VIDCOn_HST0_HPW_MSK) >> AG903_VIDCOn_HST0_HPW_POS;
}


/**
 * @brief         VIDCOnHST1 レジスタ取得
 * @param         id [in] チャンネル番号 
 * @param         hfp [out] HFPフィールド取得値 
 * @param         hbp [out] HBPフィールド取得値 
 * @return        void
 * @description   VIDCOnHST1 レジスタ取得
*/
void AG903_VidPrmGetVIDCOnHST1(uint32_t id, uint32_t *hfp, uint32_t *hbp)
{
    uint32_t                    val;

    ASSERT(id < AG903_VID_PRM_MAX_CAPTURE_PORTS);
    ASSERT(hfp != NULL);
    ASSERT(hbp != NULL);

    val = AG903_VIDCOn(id)->HST1;

    *hfp = (val & AG903_VIDCOn_HST1_HFP_MSK) >> AG903_VIDCOn_HST1_HFP_POS;
    *hbp = (val & AG903_VIDCOn_HST1_HBP_MSK) >> AG903_VIDCOn_HST1_HBP_POS;
}


/**
 * @brief         VIDCOnVST0 レジスタ取得
 * @param         id [in] チャンネル番号 
 * @param         vst0 [out] VIDCOnVST0取得値格納先
 * @return        void
 * @description   VIDCOnVST0 レジスタ取得
*/
void AG903_VidPrmGetVIDCOnVST0(uint32_t id, VIDPrmParamVIDCOnVST0 *vst0)
{
    uint32_t                    val;

    ASSERT(id < AG903_VID_PRM_MAX_CAPTURE_PORTS);
    ASSERT(vst0 != NULL);

    val = AG903_VIDCOn(id)->VST0;

    vst0->scan = (val & AG903_VIDCOn_VST0_SCAN_MSK) >> AG903_VIDCOn_VST0_SCAN_POS;
    vst0->ebp  = (val & AG903_VIDCOn_VST0_EBP_MSK)  >> AG903_VIDCOn_VST0_EBP_POS;
    vst0->efp  = (val & AG903_VIDCOn_VST0_EFP_MSK)  >> AG903_VIDCOn_VST0_EFP_POS;
    vst0->obp  = (val & AG903_VIDCOn_VST0_OBP_MSK)  >> AG903_VIDCOn_VST0_OBP_POS;
    vst0->ofp  = (val & AG903_VIDCOn_VST0_OFP_MSK)  >> AG903_VIDCOn_VST0_OFP_POS;
    vst0->vpw  = (val & AG903_VIDCOn_VST0_VPW_MSK)  >> AG903_VIDCOn_VST0_VPW_POS;
}


/**
 * @brief         VIDCOnVST1 レジスタ取得
 * @param         id [in] チャンネル番号 
 * @param         vfp [out] VFPフィールド取得値 
 * @param         vbp [out] VBPフィールド取得値 
 * @return        void
 * @description   VIDCOnVST1 レジスタ取得
*/
void AG903_VidPrmGetVIDCOnVST1(uint32_t id, uint32_t *vfp, uint32_t *vbp)
{
    uint32_t                    val;

    ASSERT(id < AG903_VID_PRM_MAX_CAPTURE_PORTS);
    ASSERT(vfp != NULL);
    ASSERT(vbp != NULL);

    val = AG903_VIDCOn(id)->VST1;

    *vfp = (val & AG903_VIDCOn_VST1_VFP_MSK) >> AG903_VIDCOn_VST1_VFP_POS;
    *vbp = (val & AG903_VIDCOn_VST1_VBP_MSK) >> AG903_VIDCOn_VST1_VBP_POS;
}


/**
 * @brief         VIDCOnFST レジスタ取得
 * @param         id [in] チャンネル番号 
 * @param         vfs [out] VFSフィールド取得値 
 * @param         hfs [out] HFSフィールド取得値 
 * @return        void
 * @description   VIDCOnFST レジスタ取得
*/
void AG903_VidPrmGetVIDCOnFST(uint32_t id, uint32_t *vfs, uint32_t *hfs)
{
    uint32_t                    val;

    ASSERT(id < AG903_VID_PRM_MAX_CAPTURE_PORTS);
    ASSERT(vfs != NULL);
    ASSERT(hfs != NULL);

    val = AG903_VIDCOn(id)->FST;

    *vfs = (val & AG903_VIDCOn_FST_VFS_MSK) >> AG903_VIDCOn_FST_VFS_POS;
    *hfs = (val & AG903_VIDCOn_FST_HFS_MSK) >> AG903_VIDCOn_FST_HFS_POS;
}
