📄 philips_dtv_ref3.c
字号:
/*
* Copyright (c) 1995 - 1999 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_ref3.c 1.18
*
* Last update : 18:59:27 - 00/11/09
*
* Description :
*
* Board Support Package for Trimedia peripherals. This particular file supports
* the Philips dtv ref3(gomad) board. The purpose of this file is to define
* philips_dtv_ref3_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/tmPCI.h>
#include <tm1/tsaIR.h>
#include <tm1/tmInterrupts.h>
/* local includes */
#include "philips_dtv_ref3.h"
#include "saa7112.h" /* video decoder */
#include "st7545.h"
#include "dtv_ref3_audio.h"
#include "dtv_ref3_video.h" /* video encoder */
#include "voSupport.h"
#include "ref3_prphr_int.h"
#include "w83977atf.h"
/* debug level is the or'ed value of the different levels of messages you */
/* want. For example, with DEBUG_LEVEL 6, you enable both L2 and L4 DPs */
#define DEBUG_LEVEL 0
#if (DEBUG_LEVEL & 1)
#define L1_DP(x) DP(x)
#endif
#if (DEBUG_LEVEL & 2)
#define L2_DP(x) DP(x)
#endif
#if (DEBUG_LEVEL & 4)
#define L3_DP(x) DP(x)
#endif
/* making sure that the Lx_DP macros are defined */
#ifndef L1_DP
#define L1_DP(x)
#endif
#ifndef L2_DP
#define L2_DP(x)
#endif
#ifndef L3_DP
#define L3_DP(x)
#endif
#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)
/* address of boot eeprom: Define in C because it might be different on another board. */
#define IIC_EEPROM_ADDRESS 0xA1
#define VO_FREQUENCY 27000000.0 /* 27 MHz */
/* forward declarations of functions defined in this module */
static tmLibdevErr_t dtv_ref3_board_activate(pcomponent_t comp);
static tmLibdevErr_t dtv_ref3_board_detect(void);
static tmLibdevErr_t dtv_ref3_board_init(void);
static tmLibdevErr_t dtv_ref3_board_register(pcomponent_t comp);
extern tmLibdevErr_t _dtvRef3RegisterUart(void);
/* SIO access functions */
static tmLibdevErr_t ref3SioWrite (UInt32 sioAddress, UInt8 data);
/* declaration of PIC functions */
static tmLibdevErr_t dtvRef3PICInit(UInt32 source);
static tmLibdevErr_t dtvRef3PICTerm(UInt32 source);
static tmLibdevErr_t dtvRef3PICStart(UInt32 source);
static tmLibdevErr_t dtvRef3PICStop(UInt32 source);
static tmLibdevErr_t dtvRef3PICAck(UInt32 source);
static Bool dtvRef3PICSourceDetect(UInt32 * source);
/* declaration of IR functions */
static tmLibdevErr_t dtvRef3IRInit(pboardIRParam_t params);
static tmLibdevErr_t dtvRef3IRTerm(void);
static tmLibdevErr_t dtvRef3IRStart(void);
static tmLibdevErr_t dtvRef3IRStop(void);
static void dtvRef3IRGetEvent(tsaIREvent_t *event, UInt32 *value);
/* PIC support */
#define DTV_REF3_PIC_NUM_SUPPORTED_INTS 1
#define DTV_REF3_PIC_NUM_SRCS 3
static tsaPICSource_t dtvRef3PICSrcTable[DTV_REF3_PIC_NUM_SRCS] =
{picSourceComm1, picSourceComm2, picSourceIrIn0};
static boardPICIntCaps_t dtvRef3PICIntCaps[DTV_REF3_PIC_NUM_SUPPORTED_INTS] =
{
{
intINT_2, /* interrupt */
False, /* levelTriggered */
intPRIO_1, /* interrupt priority */
DTV_REF3_PIC_NUM_SRCS, /* numSources */
dtvRef3PICSrcTable,
dtvRef3PICInit, /* initFunc */
dtvRef3PICTerm, /* termFunc */
dtvRef3PICSourceDetect, /* sourceDetectFunc */
dtvRef3PICStart, /* startFunc */
dtvRef3PICStop, /* stopFunc */
dtvRef3PICAck, /* ackFunc */
}
};
static boardPICConfig_t dtvRef3PIC =
{
"REF3 PIC",
DTV_REF3_PIC_NUM_SUPPORTED_INTS,
dtvRef3PICIntCaps
};
/* UART support */
static boardUartConfig_t dtvRef3Uart1 =
{
"REF3 com1 RS232",
w83977atfUartInitPort,
w83977atfUartTermPort,
w83977atfUartReadData,
w83977atfUartSetTxInt,
w83977atfUartWriteData,
w83977atfUartSetRxInt,
w83977atfUartGetEvent,
w83977atfUartConfig,
W83977ATF_SUPPORTED_BAUD_RATES
};
static boardUartConfig_t dtvRef3Uart2 =
{
"REF3 com2 TTL",
w83977atfUartInitPort,
w83977atfUartTermPort,
w83977atfUartReadData,
w83977atfUartSetTxInt,
w83977atfUartWriteData,
w83977atfUartSetRxInt,
w83977atfUartGetEvent,
w83977atfUartConfig,
W83977ATF_SUPPORTED_BAUD_RATES
};
/* IR support */
#define DTV_REF3_IR_SUPPORTED_DEVICES (irdRC5)
static boardIRConfig_t dtvRef3IR =
{
"REF3 SIO IR",
dtvRef3IRInit, /* initFunc */
dtvRef3IRTerm, /* termFunc */
dtvRef3IRStart, /*startFunc */
dtvRef3IRStop, /* stopFunc */
Null, /* config not supported */
dtvRef3IRGetEvent, /* getEventFunc */
DTV_REF3_IR_SUPPORTED_DEVICES
};
/* Describe audio out. */
static boardAOConfig_t dtv_ao =
{
"DTV audio output",
dtv_ref3_AO_Init, /* init */
dtv_ref3_AO_Term, /* term */
dtv_ref3_AO_Start, /* start */
dtv_ref3_AO_Stop, /* stop */
dtv_ref3_AO_SetSRate, /* set srate */
dtv_ref3_AO_GetSRate, /* get srate */
Null, /* set volume */
Null, /* get volume */
Null, /* set output */
Null, /* get output */
dtv_ref3_AO_Config, /* config */
DTV_REF3_SUPPORTED_AUDIO_OUT_TYPES, /* Types supported */
DTV_REF3_SUPPORTED_AUDIO_OUT_SUBTYPES, /* subtypes supported */
DTV_REF3_OUTPUT_AUDIO_ADAPTERS,
intAUDIOOUT, /* interrupt number */
AO_STATUS, /* AO MMIO base */
50000, /* max sample rate */
20000, /* min sample rate */
0, /* gpio first pin */
0 /* gpio last pin */
};
/* Describe video out. */
static boardVOConfig_t dtv_vo =
{
"DTV VO", /* encoder name */
dtv_ref3_VO_Init, /* init */
dtv_ref3_VO_Stop, /* term */
Null, /* Hue */
Null, /* Saturation */
dtv_ref3_VO_SetBrightness, /* Brightness */
Null, /* Contrast */
dtv_ref3_VO_Configure, /* config */
DTV_REF3_VO_SUPPORTED_STANDARDS, /* supported color standards */
DTV_REF3_VO_SUPPORTED_ADAPTERS, /* supported adapters */
intVIDEOOUT, /* interrupt number */
VO_STATUS, /* mmioBase */
0, /* gpio first pin */
0 /* gpio last pin */
};
/* describe telecom's Analog Front End (AFE) */
static boardSSIConfig_t dtv_afe =
{
"none",
Null, /* setup */
Null, /* term */
Null, /* hook */
Null, /* config */
sacNoConnection, /* connection flags */
Null, /* reserved */
intINT_15,
0, /* gpio first pin */
0 /* gpio last pin */
};
/***********************************************************************/
static tmLibdevErr_t ref3SioWrite (UInt32 sioAddress, UInt8 data)
{
return pciIOWriteUInt8(sioAddress, (UInt32) data);
}
/************************************* PIC functions **************************************/
static UInt32 int0InitCount = 0;
static UInt8 ref3PicMasterMask, ref3PicSlaveMask;
#define REF3_COM1_IRQ 0x04
#define REF3_COM2_IRQ 0x03
#define REF3_IR_IRQ 0x05
#define REF3_LPT1_IRQ 0x07
#define REF3_KBD_IRQ 0x06
static UInt8 ref3IrqArray[DTV_REF3_PIC_NUM_SRCS] =
{
REF3_COM1_IRQ,
REF3_COM2_IRQ,
REF3_IR_IRQ
};
static UInt8 ref3Irq2SrcArray[16] =
{
0xff,
0xff,
0xff,
1,
0,
2,
4,
3,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff,
0xff
};
static tmLibdevErr_t dtvRef3PICInit(UInt32 source)
{
UInt8 irqNum;
tmLibdevErr_t err;
if (source >= DTV_REF3_PIC_NUM_SRCS)
return PIC_ERR_SOURCE_NOT_AVAILABLE;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -