📄 philips_dtv_nim.c
字号:
/*
* Copyright (c) 1998,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_nim.c 1.28
*
* Last update : 18:52:02 - 00/11/09
*
* Description :
*
* Board Support Package for the NIM board. This board is a daughter
* board of the dtv reference 3 board (GOMAD).
*
* Revision :
*
*
*/
#include <string.h>
#include <tmlib/dprintf.h>
#include <tm1/tmAvFormats.h>
#include <tm1/mmio.h>
#include <tm1/tmInterrupts.h>
#include <tm1/tmAssert.h>
#include <tm1/tmBoard.h>
#include <tm1/tmBoardID.h>
#include <tm1/tsaReg.h>
#include <tm1/tsaComponent.h>
#include <tm1/tmVI.h>
#include <tm1/tmTP.h>
#include <tm1/tmIIC.h>
#include <tm1/tmGPIOpins.h>
#include <tm1/tmProcessor.h>
#include "saa7112.h"
#include "saa7114.h"
#include "nim.h"
#include "iicDirection.h"
#include "fi1236mk2.h"
#include "tda9850.h"
#define DEBUG_LEVEL 1
#if (DEBUG_LEVEL & 1)
#define L1_DP(x) DP(x)
#endif
#if (DEBUG_LEVEL & 2)
#define L2_DP(x) DP(x)
#endif
#ifndef L1_DP
#define L1_DP(x)
#endif
#ifndef L2_DP
#define L2_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)
static tmLibdevErr_t nim_board_activate(pcomponent_t comp);
static tmLibdevErr_t getNumberOfUnits(UInt32 *pNumberOfUnits, Char *searchString);
typedef enum {
vdtNone,
vdtSAA7111,
vdtSAA7111A,
vdtSAA7112,
vdtSAA7112V0,
vdtSAA7113,
vdtSAA7113A,
vdtSAA7113V0,
vdtSAA7114,
} tmVideoDecoder_t;
static tmLibdevErr_t nim_board_detectDecoder(tmVideoDecoder_t *decoder, int *nSlaveAddr);
static boardAIConfig_t nim_ai_1 =
{
"NIM AI 1",
nim_AI1_Init, /* init */
nim_AI1_Term, /* term */
nim_AI1_Start, /* start */
nim_AI1_Stop, /* stop */
nim_AI1_SetSrate, /* set srate */
nim_AI1_GetSrate, /* get srate */
Null, /* set volume */
Null, /* get volume */
nim_AI1_SetInput, /* set input */
nim_AI1_GetInput, /* get input */
nim_AI1_Config, /* config */
nim_AI1_GetFormat, /* getFormat */
NIM_SUPPORTED_AUDIO_IN_TYPES, /* Types supported */
NIM_SUPPORTED_AUDIO_IN_SUBTYPES, /* subtypes supported */
NIM_SUPPORTED_AUDIO_ADAPTERS, /* audioAdapters */
intAUDIOIN, /* interrupt */
AI1_STATUS, /* mmioBase */
50000, /* max sample rate */
20000, /* min sample rate */
GPIO_AI1_OSCLK, /* gpio first pin */
GPIO_AI1_WS /* gpio last pin */
};
static boardAIConfig_t nim_ai_2 =
{
"NIM AI 2",
nim_AI2_Init, /* init */
nim_AI2_Term, /* term */
nim_AI2_Start, /* start */
nim_AI2_Stop, /* stop */
nim_AI2_SetSrate, /* set srate */
nim_AI2_GetSrate, /* get srate */
Null, /* set volume */
Null, /* get volume */
nim_AI2_SetInput, /* set input */
nim_AI2_GetInput, /* get input */
nim_AI2_Config, /* config */
nim_AI2_GetFormat, /* getFormat */
NIM_SUPPORTED_AUDIO_IN_TYPES & ~atf1937, /* Types supported, we can't support digital
audio in on the current TM2 chips. */
NIM_SUPPORTED_AUDIO_IN_SUBTYPES, /* subtypes supported */
NIM_SUPPORTED_AUDIO_ADAPTERS & ~aaaDigitalInput, /* audioAdapters, we can't support digital
audio in on the current TM2 chips. */
intAUDIOIN2, /* interrupt */
AI2_STATUS, /* mmioBase */
50000, /* max sample rate */
20000, /* min sample rate */
GPIO_AI2_OSCLK, /* gpio first pin */
GPIO_AI2_WS /* gpio last pin */
};
static tmLibdevErr_t nim_TP_Init_1(void);
static tmLibdevErr_t nim_TP_Init_2(void);
static tmLibdevErr_t nim_TP_Term(void);
static tmLibdevErr_t nim_TP_Config(UInt32 address, UInt32 value);
static boardTPConfig_t nim_tp_1 =
{
"NIM TP input 1",
nim_TP_Init_1, /* init */
nim_TP_Term, /* term */
nim_TP_Config, /* config */
True, /* onlySampleDvalidBytes */
False, /* sampleOnNegativeEdge */
intTRANSPORTIN1, /* interrupt */
TP1_STATUS, /* mmioBase */
GPIO_VI1_CLK, /* gpio first pin */
GPIO_VI1_DATA9 /* gpio last pin */
};
static boardTPConfig_t nim_tp_2 =
{
"NIM TP input 2",
nim_TP_Init_2, /* init */
nim_TP_Term, /* term */
nim_TP_Config, /* config */
True, /* onlySampleDvalidBytes */
False, /* sampleOnNegativeEdge */
intTRANSPORTIN2, /* interrupt */
TP2_STATUS, /* mmioBase */
GPIO_VI2_CLK, /* gpio first pin */
GPIO_VI2_DATA9 /* gpio last pin */
};
static tmLibdevErr_t mapAdapter2Mode(pboardVIDec_t pVD, tmVideoAnalogAdapter_t adapter, UInt adapterInstance, UInt *mode);
static tmLibdevErr_t mapMode2Adapter(pboardVIDec_t pVD, UInt mode, tmVideoAnalogAdapter_t *adapter, UInt *adapterInstance);
static tmLibdevErr_t nim_VI_Init_1(pboardVIParam_t param);
static tmLibdevErr_t nim_VI_GetStandard_1(tmVideoAnalogStandard_t *standard);
static tmLibdevErr_t nim_VI_SetHue_1(UInt value);
static tmLibdevErr_t nim_VI_SetSaturation_1(UInt value);
static tmLibdevErr_t nim_VI_Configure_1(UInt32 subaddr, UInt32 value);
static tmLibdevErr_t nim_VI_SetContrast_1(UInt32 value);
static tmLibdevErr_t nim_VI_SetBrightness_1(UInt value);
static tmLibdevErr_t nim_VI_Init_2(pboardVIParam_t param);
static tmLibdevErr_t nim_VI_GetStandard_2(tmVideoAnalogStandard_t *standard);
static tmLibdevErr_t nim_VI_SetHue_2(UInt value);
static tmLibdevErr_t nim_VI_SetSaturation_2(UInt value);
static tmLibdevErr_t nim_VI_Configure_2(UInt32 subaddr, UInt32 value);
static tmLibdevErr_t nim_VI_SetContrast_2(UInt32 value);
static tmLibdevErr_t nim_VI_SetBrightness_2(UInt value);
static tmLibdevErr_t nim_VI_GetStatus(pboardVIDec_t pVD, tmVideoStatusType_t type, UInt *state);
static tmLibdevErr_t nim_VI_GetAdapterStandard(pboardVIDec_t pVD, tmVideoAnalogAdapter_t adapter, UInt adapterNum, tmVideoAnalogStandard_t *standard);
static tmLibdevErr_t nim_VI_SetSourceType(pboardVIDec_t pVD, tmVideoSourceType_t type);
static tmLibdevErr_t nim_VI_GetVSyncFallingEdge(pboardVIDec_t pVD, UInt *lineNumber);
static tmLibdevErr_t nim_VI_GetDefaultAcquisitionWnd(pboardVIDec_t pVD, UInt *beginX, UInt *beginY, UInt *endX, UInt *endY);
static tmLibdevErr_t nim_VI_SetAnalogInput(pboardVIDec_t pVD, tmVideoAnalogAdapter_t adapter, UInt adapterInstance);
static tmLibdevErr_t nim_VI_GetAnalogInput(pboardVIDec_t pVD, tmVideoAnalogAdapter_t *adapter, UInt *adapterInstance);
/* tuner support */
static tmLibdevErr_t nimTunerInit_1(pboardTvTunerParameters_t params);
static tmLibdevErr_t nimTunerTerm_1(void);
static tmLibdevErr_t nimTunerConfig_1(UInt32 command, Pointer value);
static tmLibdevErr_t nimTunerSetChannel_1(ptsaTvTunerChannelParams_t chanParams);
static tmLibdevErr_t nimTunerConfigChannel_1(UInt32 command, Pointer value);
static tmLibdevErr_t nimTunerInit_2(pboardTvTunerParameters_t params);
static tmLibdevErr_t nimTunerTerm_2(void);
static tmLibdevErr_t nimTunerConfig_2(UInt32 command, Pointer value);
static tmLibdevErr_t nimTunerSetChannel_2(ptsaTvTunerChannelParams_t chanParams);
static tmLibdevErr_t nimTunerConfigChannel_2(UInt32 command, Pointer value);
#define NIM_TUNER_IIC_ADDRESS FI1236MK2_IIC_ADDRESS_3
static boardTvTunerConfig_t tunerConfig0 =
{
"NIM 1 FI1236MK2",
nimTunerInit_1,
nimTunerTerm_1,
nimTunerConfig_1,
nimTunerSetChannel_1,
nimTunerConfigChannel_1,
FI1236MK2_SUPPORTED_STEP_SIZES,
FI1236MK2_SUPPORTED_INPUTS,
FI1236MK2_MIN_FREQUENCY,
FI1236MK2_MAX_FREQUENCY,
{0xff, 0xff, 0xff, vaaNone, 0xff}
};
static boardTvTunerConfig_t tunerConfig1 =
{
"NIM 2 FI1236MK2",
nimTunerInit_2,
nimTunerTerm_2,
nimTunerConfig_2,
nimTunerSetChannel_2,
nimTunerConfigChannel_2,
FI1236MK2_SUPPORTED_STEP_SIZES,
FI1236MK2_SUPPORTED_INPUTS,
FI1236MK2_MIN_FREQUENCY,
FI1236MK2_MAX_FREQUENCY,
{0xff, 0xff, 0xff, vaaNone, 0xff}
};
/* Describe video input adapters */
#define NO_OF_VIDEO_ADAPTERS 3
static boardVIAdapterEntry_t nim_vi_adapters[NO_OF_VIDEO_ADAPTERS] =
{
/* The first adapter will be used as default in case vaaNone is seleted */
{ vaaSvideo, 0, 9 }, /* S-Video adapter 0 at input mode 9 */
{ vaaCVBS, 0, 4 }, /* CVBS via S-Video adapter input mode 1 */
{ vaaCVBS, 1, 5 } /* tuner input through CVBS */
};
static boardVIConfig_t nim_vi_1 =
{
"", /* decoder name */
nim_VI_Init_1, /* decode init */
Null, /* decoder term */
nim_VI_GetStandard_1, /* get standard */
nim_VI_SetHue_1,
nim_VI_SetSaturation_1,
nim_VI_SetBrightness_1,
nim_VI_SetContrast_1,
nim_VI_Configure_1, /* config */
vasNone, /* supported color standards, will be set later (based on detected video decoder) */
vaaNone, /* supported adapters, will be set later (based on detected video decoder) */
intVIDEOIN,
VI1_STATUS,
GPIO_VI1_CLK, /* gpio first pin */
GPIO_VI1_DATA9, /* gpio last pin */
0, /* capabilities flags, will be set later (based on detected video decoder) */
0, /* output formats, will be set later (based on detected video decoder) */
nim_VI_GetVSyncFallingEdge, /* returns line number of VSync falling edge */
Null, /* returns sliced Closed Caption data */
nim_VI_GetStatus, /* get status information about video source */
Null, /* returns supported services for each VBI line */
Null, /* sets data services to be sliced */
Null, /* enables HW slicing */
Null, /* set video standard for slicer */
Null, /* get slicer's video standard */
Null, /* toggle slicer's field ID */
Null, /* set input of slicer */
Null, /* get slicer's input */
Null, /* set BCSH for active video */
Null, /* get BCSH for active video */
nim_VI_SetAnalogInput, /* set video input mode */
nim_VI_GetAnalogInput, /* get video input mode */
Null, /* set video standard */
nim_VI_SetSourceType, /* set video source type */
Null, /* get video source type */
Null, /* set the video's output format */
Null, /* get the video's output format */
Null, /* set video acquisition window */
Null, /* get video acquisition window */
nim_VI_GetDefaultAcquisitionWnd,/* get the default acquisition window */
Null, /* set video output size */
Null, /* set interlaced mode */
Null, /* disable video decoder */
Null, /* set power save mode */
Null, /* get number of GPIOs on decoder */
Null, /* set the state of one GPIO pin */
Null, /* get a GPIO pin's state */
Null, /* open VBI decoder */
Null, /* enable VBI */
Null, /* set VBI mode */
Null, /* set the slicer's mode */
Null, /* close VBI decoder */
Null, /* Get input status for every line */
{ 0x40, /* decoder's I2C slave address */
NO_OF_VIDEO_ADAPTERS, /* number of adapters */
nim_vi_adapters, /* mapping table of adapters to inputs */
vasNone, /* current video standard */
IIC_DIRECTION_NIM1, /* iic direction */
Null}, /* handle, not used */
nim_VI_GetAdapterStandard /* Get the standard for a specific adapter */
};
static boardVIConfig_t nim_vi_2 =
{
"", /* decoder name */
nim_VI_Init_2, /* decode init */
Null, /* decoder term */
nim_VI_GetStandard_2, /* get standard */
nim_VI_SetHue_2,
nim_VI_SetSaturation_2,
nim_VI_SetBrightness_2,
nim_VI_SetContrast_2,
nim_VI_Configure_2, /* config */
vasNone, /* supported color standards, will be set later (based on detected video decoder) */
vaaNone, /* supported adapters, will be set later (based on detected video decoder) */
intVIDEOIN2,
VI2_STATUS,
GPIO_VI2_CLK, /* gpio first pin */
GPIO_VI2_DATA9, /* gpio last pin */
0, /* capabilities flags, will be set later (based on detected video decoder) */
0, /* output formats, will be set later (based on detected video decoder) */
nim_VI_GetVSyncFallingEdge, /* returns line number of VSync falling edge */
Null, /* returns sliced Closed Caption data */
nim_VI_GetStatus, /* get status information about video source */
Null, /* returns supported services for each VBI line */
Null, /* sets data services to be sliced */
Null, /* enables HW slicing */
Null, /* set video standard for slicer */
Null, /* get slicer's video standard */
Null, /* toggle slicer's field ID */
Null, /* set input of slicer */
Null, /* get slicer's input */
Null, /* set BCSH for active video */
Null, /* get BCSH for active video */
nim_VI_SetAnalogInput, /* set video input mode */
nim_VI_GetAnalogInput, /* get video input mode */
Null, /* set video standard */
nim_VI_SetSourceType, /* set video source type */
Null, /* get video source type */
Null, /* set the video's output format */
Null, /* get the video's output format */
Null, /* set video acquisition window */
Null, /* get video acquisition window */
nim_VI_GetDefaultAcquisitionWnd, /* get the default acquisition window */
Null, /* set video output size */
Null, /* set interlaced mode */
Null, /* disable video decoder */
Null, /* set power save mode */
Null, /* get number of GPIOs on decoder */
Null, /* set the state of one GPIO pin */
Null, /* get a GPIO pin's state */
Null, /* open VBI decoder */
Null, /* enable VBI */
Null, /* set VBI mode */
Null, /* set the slicer's mode */
Null, /* close VBI decoder */
Null, /* Get input status for every line */
{ 0x40, /* decoder's I2C slave address */
NO_OF_VIDEO_ADAPTERS, /* number of adapters */
nim_vi_adapters, /* mapping table of adapters to inputs */
vasNone, /* current video standard */
IIC_DIRECTION_NIM2, /* iic direction */
Null}, /* handle, not used */
nim_VI_GetAdapterStandard /* Get the standard for a specific adapter */
};
/* IDs for used video decoders. */
static UInt id7112 = 0x7112;
static UInt id7114 = 0x7114;
static tmLibdevErr_t nimAudDemInit(unitSelect_t unitID, pboardTvAudDemParameters_t params);
static tmLibdevErr_t nimAudDemConfig(unitSelect_t unitID, UInt32 command, Pointer Value);
static boardTvAudDemConfig_t audDemConfig0 =
{
"NIM - TDA9850",
nimAudDemInit, /* initFunc */
tda9850Term, /* termFunc */
nimAudDemConfig, /* configFunc */
tda9850Start, /* startFunc */
tda9850Stop, /* stopFunc */
tda9850GetStatus, /* getStatusFunc */
TDA9850_SUPPORTED_AUDIO_MODES, /* supportedAudioModes */
unit0, /* aiUnit */
aaaAuxInput1, /* aiAnalogAdapter */
unit0 /* tunerID */
};
static boardTvAudDemConfig_t audDemConfig1 =
{
"NIM - TDA9850",
nimAudDemInit, /* initFunc */
tda9850Term, /* termFunc */
nimAudDemConfig, /* configFunc */
tda9850Start, /* startFunc */
tda9850Stop, /* stopFunc */
tda9850GetStatus, /* getStatusFunc */
TDA9850_SUPPORTED_AUDIO_MODES, /* supportedAudioModes */
unit1, /* aiUnit */
aaaAuxInput1, /* aiAnalogAdapter */
unit1 /* tunerID */
};
static unitSelect_t audDemUnitID0 = (unitSelect_t) 0xff;
static unitSelect_t audDemUnitID1 = (unitSelect_t) 0xff;
static tmLibdevErr_t mapAdapter2Mode(pboardVIDec_t pVD, tmVideoAnalogAdapter_t adapter, UInt adapterInstance, UInt *mode)
{
UInt i;
/* If this is vaaNone then use the default adapter */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -