📄 philips_dtv_ref2.c
字号:
/*
* Copyright (c) 1995,1996,1997 by TriMedia Technologies.
*
* +------------------------------------------------------------------+
* | This software is furnished under a license and may only be used |
* | and copied in accordance with the terms and conditions of such |
* | a license and with the inclusion of this copyright notice. This |
* | software or any other copies of this software may not be provided|
* | or otherwise made available to any other person. The ownership |
* | and title of this software is not transferred. |
* | |
* | The information in this software is subject to change without |
* | any prior notice and should not be construed as a commitment by |
* | TriMedia Technologies. |
* | |
* | this code and information is provided "as is" without any |
* | warranty of any kind, either expressed or implied, including but |
* | not limited to the implied warranties of merchantability and/or |
* | fitness for any particular purpose. |
* +------------------------------------------------------------------+
*
* Module name : philips_dtv_ref2.c 1.29
* Last update : 18:53:23 - 00/11/09
*
* Description :
*
* Board Support Package for Trimedia peripherals. This particular file supports
* the Philips dtv board. The purpose of this file is to define
* philips_dtv_ref2_config. This board config structure will be included in a
* table in boardcfg.c
*
* This file also defines many of the functions and structures which are
* referenced in the board config structure.
*
* Revision :
*
*
*/
/* includes of system H files */
#include <tm1/tmBoardID.h>
#include <tmlib/dprintf.h>
#include <tm1/tmBoard.h>
#include <tm1/mmio.h>
#include <tm1/tmProcessor.h>
#include <tm1/tmAvFormats.h>
#include <tm1/tsaComponent.h>
#include <tm1/tmVImmio.h>
#include <tm1/tmVOmmio.h>
#include <tm1/tsaFlash.h>
#include "philips_dtv_ref2.h"
#include "saa7111.h" /* defines for video in decoder */
#include "saa7125.h" /* defines for video out encoder */
#include "st7545.h"
#include "dtv_ref2_audio.h"
#include "voSupport.h"
#include "pc16552D.h"
#define DEBUG_LEVEL 0
#if (DEBUG_LEVEL == 0)
#define L1_DP(x)
#define L2_DP(x)
#endif
#if (DEBUG_LEVEL == 1)
#define L1_DP(x) DP(x)
#define L2_DP(x)
#endif
#if (DEBUG_LEVEL == 2)
#define L1_DP(x)
#define L2_DP(x) DP(x)
#endif
#if (DEBUG_LEVEL == 3)
#define L1_DP(x) DP(x)
#define L2_DP(x) DP(x)
#endif
/* address of boot eeprom: Define in C because it might be different on another board. */
#define IIC_EEPROM_ADDRESS 0xA1
#define VO_INIT_FREQ 27000000.0 /* 27 MHz */
#define TRY(x) \
do { \
tmLibdevErr_t _err = (x); \
if (_err != TMLIBDEV_OK) { \
L2_DP(("Failed at line %d in file %s. Err = %x\n", __LINE__, __FILE__, _err)); \
return _err; \
}} while (0)
/* forward declarations of functions defined in this module */
static tmLibdevErr_t dtv_ref2_board_activate(pcomponent_t comp);
static tmLibdevErr_t dtv_ref2_board_init(void);
static tmLibdevErr_t dtv_ref2_board_detect(void);
static tmLibdevErr_t dtv_ref2_board_register(pcomponent_t comp);
/* forward declarations of flash functions defined in this module */
static tmLibdevErr_t ref2FlashInit(void);
static tmLibdevErr_t ref2FlashReadWord(UInt32 address, UInt32 * data);
static tmLibdevErr_t ref2FlashWriteWord(UInt32 address, UInt32 data);
static tmLibdevErr_t ref2FlashReadBlock(UInt32 address, UInt32 * data, UInt32 numberOfWords);
static tmLibdevErr_t ref2FlashWriteBlock(UInt32 address, UInt32 * data, UInt32 numberOfWords);
static tmLibdevErr_t ref2FlashEraseSector(UInt32 sector);
static tmLibdevErr_t ref2FlashEraseAll(void);
/* functions to read and write registers of the PC16552D */
static UInt8 dtvRef2ReadUartRegister(unitSelect_t portID, Int addr);
static void dtvRef2WriteUartRegister(unitSelect_t portID, Int addr,UInt8 data);
/* PIC support
* on this board, the PIC is a software only construct.
*/
#define DTV_REF2_PIC_NUM_SUPPORTED_INTS 2
#define DTV_REF2_PIC_NUM_SRCS 2
static tmLibdevErr_t dtvRef2PICInit(UInt32 source);
static tmLibdevErr_t dtvRef2PICTerm(UInt32 source);
static tmLibdevErr_t dtvRef2PICStart(UInt32 source);
static tmLibdevErr_t dtvRef2PICStop(UInt32 source);
static tmLibdevErr_t dtvRef2PICAck(UInt32 source);
static tsaPICSource_t dtvRef2PICSrcTableComm[DTV_REF2_PIC_NUM_SRCS] =
{picSourceComm1, picSourceComm2};
static tsaPICSource_t dtvRef2PICSrcTableAI[DTV_REF2_PIC_NUM_SRCS] =
{picSourceAudio1};
static boardPICIntCaps_t dtvRef2PICIntCaps[DTV_REF2_PIC_NUM_SUPPORTED_INTS] =
{
{ /* to support the Uart library */
inPCI_PINC, /* interrupt */
True, /* levelTriggered */
intPRIO_2, /* interrupt priority */
DTV_REF2_PIC_NUM_SRCS, /* numSources */
dtvRef2PICSrcTableComm,
dtvRef2PICInit, /* initFunc */
dtvRef2PICTerm, /* termFunc */
pc16552DPICSourceDetect, /* sourceDetectFunc */
dtvRef2PICStart, /* startFunc */
dtvRef2PICStop, /* stopFunc */
dtvRef2PICAck, /* ackFunc */
},
{ /* to support the audio digitizer */
intTRI_USERIRQ, /* interrupt */
False, /* levelTriggered */
intPRIO_4, /* interrupt priority */
1, /* numSources */
dtvRef2PICSrcTableAI,
dtvRef2PICInit, /* initFunc */
dtvRef2PICTerm, /* termFunc */
Null, /* sourceDetectFunc */
dtvRef2PICStart, /* startFunc */
dtvRef2PICStop, /* stopFunc */
dtvRef2PICAck, /* ackFunc */
},
};
static boardPICConfig_t dtvRef2PIC =
{
"DTV REF2 PIC",
DTV_REF2_PIC_NUM_SUPPORTED_INTS,
dtvRef2PICIntCaps
};
/* UART support */
static boardUartConfig_t dtvRef2Uart1 =
{
"PC16552D com1",
pc16552DInitPort,
pc16552DTermPort,
pc16552DReadData,
pc16552DSetTxInt,
pc16552DWriteData,
pc16552DSetRxInt,
pc16552DGetEvent,
pc16552DUartConfig,
PC16552D_BAUD_RATES_1_8432
};
static boardUartConfig_t dtvRef2Uart2 =
{
"PC16552D com2",
pc16552DInitPort,
pc16552DTermPort,
pc16552DReadData,
pc16552DSetTxInt,
pc16552DWriteData,
pc16552DSetRxInt,
pc16552DGetEvent,
pc16552DUartConfig,
PC16552D_BAUD_RATES_1_8432
};
/* flash support */
static boardFlashConfig_t ref2Flash =
{
"Am29F016",
ref2FlashInit,
ref2FlashReadWord,
ref2FlashWriteWord,
ref2FlashReadBlock,
ref2FlashWriteBlock,
ref2FlashEraseSector,
ref2FlashEraseAll,
DTV_REF2_FLASH_SIZE,
DTV_REF2_FLASH_SECTOR_NR,
DTV_REF2_FLASH_SECTOR_SIZE,
0xffffffff
};
/* Describe audio in. */
static boardAIConfig_t dtv_ai =
{
"DTV audio input",
dtv_ref2_AI_Init, /* setup */
dtv_ref2_AI_Term, /* term */
dtv_ref2_AI_Start, /* start */
dtv_ref2_AI_Stop, /* stop */
dtv_ref2_AI_SetSrate, /* set srate */
dtv_ref2_AI_GetSrate, /* get srate */
Null, /* set volume */
Null, /* get volume */
dtv_ref2_AI_SetInput, /* set input */
dtv_ref2_AI_GetInput, /* get input */
dtv_ref2_AI_Config, /* config */
dtv_ref2_AI_GetFormat, /* getFormat */
DTV_REF2_SUPPORTED_AUDIO_IN_TYPES, /* Types supported */
DTV_REF2_SUPPORTED_AUDIO_IN_SUBTYPES, /* subtypes supported */
DTV_REF2_INPUT_AUDIO_ADAPTERS, /* audioAdapters */
intAUDIOIN, /* interrupt */
AI_STATUS, /* mmioBase */
50000,
20000,
0, /* gpio first pin */
0 /* gpio last pin */
};
/* Describe audio out. */
static boardAOConfig_t dtv_ao =
{
"DTV audio output",
dtv_ref2_AO_Init,
dtv_ref2_AO_Term,
dtv_ref2_AO_Start, /* start */
dtv_ref2_AO_Stop, /* stop */
dtv_ref2_AO_SetSRate, /* set srate */
dtv_ref2_AO_GetSRate, /* get srate */
Null, /* set volume */
Null, /* get volume */
Null, /* set output */
Null, /* get output */
dtv_ref2_AO_Config, /* config */
DTV_REF2_SUPPORTED_AUDIO_OUT_TYPES, /* Types supported */
DTV_REF2_SUPPORTED_AUDIO_OUT_SUBTYPES, /* subtypes supported */
DTV_REF2_OUTPUT_AUDIO_ADAPTERS, /* audioAdapters */
intAUDIOOUT, /* interrupt */
AO_STATUS, /* mmioBase */
50000, /* max sRate */
20000, /* min sRate */
0, /* gpio first pin */
0 /* gpio last pin */
};
/* FIXME : VI is never used, and there is dummy functions instead. If VI is */
/* not supported by the board, there is no trying creating a dummy structure*/
/* with the component manager. Just skip it. We leave it for now, but it */
/* place holders for VI */
static tmLibdevErr_t dummyRef2ViInit(pboardVIParam_t param) { return TMLIBDEV_OK; }
static tmLibdevErr_t dummyRef2ViConfigure(UInt32 subaddr, UInt32 value) { return TMLIBDEV_OK; }
static tmLibdevErr_t dummyRef2ViGetStandard(tmVideoAnalogStandard_t * std) { return TMLIBDEV_OK; }
static tmLibdevErr_t dummyRef2ViSetBrightness(UInt val) { return TMLIBDEV_OK; }
static tmLibdevErr_t dummyRef2ViSetContrast(UInt val) { return TMLIBDEV_OK; }
static tmLibdevErr_t dummyRef2ViSetSaturation(UInt val) { return TMLIBDEV_OK; }
static tmLibdevErr_t dummyRef2ViSetHue(UInt val) { return TMLIBDEV_OK; }
#if 0
/* FIXME */
/* The video slicing API is not stabilized. This is therefore commented out */
static tmLibdevErr_t dummyRef2ViGetVSyncFallingEdge(UInt *lineNumber) { return TMLIBDEV_OK; }
static tmLibdevErr_t dummyRef2ViGetSlicedData(UInt8 *Y, UInt8 *U, UInt *V, boardVIDataService_t service, UInt size, UInt8 *data, UInt8 *dataSize) { return TMLIBDEV_OK; }
static tmLibdevErr_t dummyRef2ViGetStatus(boardVIStatusType_t type, UInt *state) { return TMLIBDEV_OK; }
static tmLibdevErr_t dummyRef2ViGetSupportedDataServices(boardVIDataService_t fieldOne[], boardVIDataService_t fieldTwo[]) { return TMLIBDEV_OK; }
static tmLibdevErr_t dummyRef2ViSetDataServices(boardVIDataService_t fieldOne[], boardVIDataService_t fieldTwo[]) { return TMLIBDEV_OK; }
static tmLibdevErr_t dummyRef2ViEnableSlicing(Bool enable) { return TMLIBDEV_OK; }
#endif
/* Describe video in. */
static boardVIConfig_t dtv_vi =
{
"None",
dummyRef2ViInit, /* decode init */
Null, /* decoder term */
dummyRef2ViGetStandard, /* get standard */
dummyRef2ViSetHue,
dummyRef2ViSetSaturation,
dummyRef2ViSetBrightness,
dummyRef2ViSetContrast,
dummyRef2ViConfigure, /* config */
vasNone, /* supported color standards: these should not be required */
vaaNone, /* supported adapters */
intVIDEOIN, /* interrupt number */
VI_STATUS, /* mmioBase */
0, /* gpio first pin */
0 /* gpio last pin */
/* FIXME */
/* the rest of the functions is not stabilized. Therefore we leave the */
/* rest of the structure empty (everything is default to Null) */
};
/*********************************** PIC Support ************************************/
static tmLibdevErr_t dtvRef2PICInit(UInt32 source)
{
return TMLIBDEV_OK;
}
static tmLibdevErr_t dtvRef2PICTerm(UInt32 source)
{
return TMLIBDEV_OK;
}
static tmLibdevErr_t dtvRef2PICStart(UInt32 source)
{
return TMLIBDEV_OK;
}
static tmLibdevErr_t dtvRef2PICStop(UInt32 source)
{
return TMLIBDEV_OK;
}
static tmLibdevErr_t dtvRef2PICAck(UInt32 source)
{
return TMLIBDEV_OK;
}
/*********************************** UART Support ************************************/
#define Uart_COMM1_IOBASE_ADDR 0xff200100 /* Uart COMM1 I/O base address */
#define Uart_COMM2_IOBASE_ADDR 0xff200000 /* Uart COMM2 I/O base address */
static UInt8 dtvRef2ReadUartRegister(unitSelect_t portID, Int addr)
{
UInt8 Result;
UInt8* pCommPtr;
if (portID == unit0)
pCommPtr = (UInt8* ) Uart_COMM1_IOBASE_ADDR;
else
pCommPtr = (UInt8* ) Uart_COMM2_IOBASE_ADDR;
Result= *(pCommPtr + (addr*4) ) & 0xff;
return Result;
}
static void dtvRef2WriteUartRegister(unitSelect_t portID, Int addr,UInt8 data)
{
UInt8* pCommPtr;
if (portID == unit0)
pCommPtr = (UInt8*) Uart_COMM1_IOBASE_ADDR;
else
pCommPtr = (UInt8*) Uart_COMM2_IOBASE_ADDR;
*(pCommPtr + (addr*4) ) = data;
}
/*********************************** Flash Support ************************************/
static Bool flashInitialized = False;
volatile static UInt32 *flashBaseAddress = (UInt32 *) DTV_REF2_FLASH_BASE_ADDRESS;
static tmLibdevErr_t ref2FlashInit(void)
{
flashInitialized = True;
return TMLIBDEV_OK;
}
static tmLibdevErr_t ref2FlashReadWord(UInt32 address, UInt32 * data)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -