- /*****************************************************************************
- File name : denc.c
- Description : DENC Commands
- COPYRIGHT (C) 2004 STMicroelectronics
- *****************************************************************************/
- /* Includes --------------------------------------------------------------- */
- #include <string.h>
- #include "stlite.h"
- #include "stdevice.h"
- #include "sttbx.h"
- #include "errors.h"
- #include "denc.h"
- #include "service.h"
- /* Private Constants -------------------------------------------------- */
- /* Private Variables -------------------------------------------------- */
- /* Private Macros ----------------------------------------------------- */
- /* Private Function prototypes ---------------------------------------- */
- /* Global Variables ------------------------------------------------------- */
- STDENC_Handle_t DENC_Handle;
- ST_DeviceName_t g_KB_DENCDeviceName = "DENC";
- /* Functions -------------------------------------------------------------- */
- /*-------------------------------------------------------------------------
- * Function : KB_DENCSetup
- * Input : display mode (PAL/NTSC)
- * Output :
- * Return : Error Code
- * ----------------------------------------------------------------------*/
- ST_ErrorCode_t KB_DENCSetup(KB_ServiceDisplay SERVICE_Display)
- {
- ST_ErrorCode_t ST_ErrorCode;
- STDENC_InitParams_t STDENC_InitParams;
- STDENC_OpenParams_t STDENC_OpenParams = { 0 }; /* No parameters - dummy */
- STDENC_InitParams.MaxOpen = 5;
- STDENC_InitParams.DeviceType = DENC_DEVICE_TYPE;
- STDENC_InitParams.AccessType = DENC_ACCESS_TYPE;
- STDENC_InitParams.STDENC_Access.EMI.DeviceBaseAddress_p = DENC_DEVICE_BASE_ADDRESS;
- STDENC_InitParams.STDENC_Access.EMI.BaseAddress_p = (void *)DENC_BASE_ADDRESS;
- STDENC_InitParams.STDENC_Access.EMI.Width = DENC_EMI_ACCESS_WIDTH;
- STTBX_Print(("KB_DENCSetup(%s)=", g_KB_DENCDeviceName ));
- ST_ErrorCode = STDENC_Init(g_KB_DENCDeviceName, &STDENC_InitParams);
- if (ST_ErrorCode != ST_NO_ERROR)
- {
- STTBX_Print(("%sn", KB_ErrorGetText(ST_ErrorCode) ));
- return( ST_ErrorCode );
- }
- STTBX_Print(("%sn", STDENC_GetRevision() ));
- STTBX_Print(("DENC_Open="));
- ST_ErrorCode = STDENC_Open(g_KB_DENCDeviceName, &STDENC_OpenParams, &DENC_Handle );
- STTBX_Print(("%sn", KB_ErrorGetText(ST_ErrorCode) ));
- if (ST_ErrorCode != ST_NO_ERROR)
- return( ST_ErrorCode );
- switch(SERVICE_Display)
- {
- case SERVICE_DISPLAY_PAL:
- ST_ErrorCode = KB_DENCSetMode( STDENC_MODE_PALBDGHI );
- break;
- case SERVICE_DISPLAY_NTSC:
- ST_ErrorCode = KB_DENCSetMode( STDENC_MODE_NTSCM );
- break;
- case SERVICE_DISPLAY_SECAM:
- ST_ErrorCode = KB_DENCSetMode( STDENC_MODE_SECAM );
- break;
- default:
- ST_ErrorCode = ST_ERROR_FEATURE_NOT_SUPPORTED;
- break;
- }
- return ( ST_ErrorCode );
- }
- /*-------------------------------------------------------------------------
- * Function : KB_DENCSetMode
- * Input : EncodingMode
- * Output :
- * Return : Error Code
- * ----------------------------------------------------------------------*/
- ST_ErrorCode_t KB_DENCSetMode( STDENC_Mode_t Mode )
- {
- ST_ErrorCode_t ST_ErrorCode;
- STDENC_EncodingMode_t STDENC_EncodingMode;
- STTBX_Print(("KB_DENCSetMode("));
- switch(Mode)
- {
- case STDENC_MODE_NTSCM:
- STTBX_Print(("STDENC_MODE_NTSCM)="));
- STDENC_EncodingMode.Option.Ntsc.Interlaced = TRUE;
- STDENC_EncodingMode.Option.Ntsc.SquarePixel = FALSE;
- STDENC_EncodingMode.Option.Ntsc.FieldRate60Hz = FALSE;
- break;
- case STDENC_MODE_PALBDGHI:
- STTBX_Print(("STDENC_MODE_PALBDGHI)="));
- STDENC_EncodingMode.Option.Pal.Interlaced = TRUE;
- STDENC_EncodingMode.Option.Pal.SquarePixel = FALSE;
- break;
- case STDENC_MODE_SECAM:
- STTBX_Print(("STDENC_MODE_SECAM)="));
- break;
- case STDENC_MODE_NTSCM_J:
- case STDENC_MODE_NTSCM_443:
- case STDENC_MODE_PALM:
- case STDENC_MODE_PALN:
- case STDENC_MODE_PALN_C:
- default:
- STTBX_Print(("?)=mode not supported.n"));
- return( ST_ERROR_BAD_PARAMETER );
- }
- STDENC_EncodingMode.Mode = Mode;
- ST_ErrorCode = STDENC_SetEncodingMode(DENC_Handle, &STDENC_EncodingMode);
- STTBX_Print(("%sn", KB_ErrorGetText(ST_ErrorCode) ));
- return ( ST_ErrorCode );
- }
- /* EOF --------------------------------------------------------------------- */