📄 vpc323xd_test.c
字号:
#include <stdio.h>#include <stdlib.h>#include <string.h>#define ALLOW_OS_CODE 1#include "rmdef/rmdef.h"#include "llad/include/gbus.h"#include "emhwlib_hal/include/emhwlib_registers.h"#include "emhwlib_hal/i2c/include/i2c_hal.h"##include "../helper/helper.h"#include "vpc323xd.h"//#include "vpc323xd_tables.h"#define APP_VERSION "vpc0.31"RMvoid show_commands(void);RMvoid show_cmdline(char* appname);RMvoid show_commands(void){ MPRINT(("q - quit\n\n")); MPRINT(("D - detect\n")); MPRINT(("I - Initialize\n")); MPRINT(("S - select input\n")); MPRINT(("t - status\n\n")); /* MPRINT(("r - read\n")); MPRINT(("w - write\n")); MPRINT(("c - send default config\n")); MPRINT(("s - set slave address\n")); MPRINT(("\n")); MPRINT(("C - Control, (d)etect, (r)eset\n")); MPRINT(("D - Demodulator, (i)nit - IMPORTANT and I2s OUT, (s)elect standard, s(t)atus\n")); MPRINT(("X - SCART1 DSP source\n")); MPRINT(("K - SCART1 OUT, (v)olume, (s)elect source\n")); MPRINT(("M - Matrix selection\n")); MPRINT(("S - SAP Detection and selection\n")); MPRINT(("\n")); MPRINT(("\n")); MPRINT(("q - quit\n")); */}RMvoid show_cmdline(char* appname){ printf("%s [i] [c board-id] [a i2c-address]\n", appname); printf("Example: %s i c 0x760e1\n\n", appname); printf("h - This message\n"); printf("i - interactive mode\n"); printf("\n"); printf("c - board configuration\n"); MPRINT(("-----------------------------------\n")); MPRINT(("Usage for c (board Configuration): c [board number]\n")); MPRINT(("Supported boards: 760e1, 760e1c2, 760e1c3, 760e1c4\n\n")); printf("a - i2c address\n\n");}int main(int argc, char* argv[]){ int argi = 1; struct llad* pLLAD; RMvoid* pGBus; struct i2c i2cConfig; VPC323XD_CONFIG vpcConfig; RMstatus s; RMascii aBuffer[255]; printf("\n"); printf("Sigma Designs "); printf(APP_VERSION); printf(" (c) 2003\n"); printf("----------------------------------------------\n"); if( (s = mum_init( 0, &pLLAD, &pGBus)) != RM_OK ) { MPRINT(("main !mum_init FAILED %d\ncheck your 86xx driver\n", s)); exit(s); } /* I'm only going to use 1 I2c bus, but you can have multiple linked to different tuners */ memset(&i2cConfig, 0, sizeof(struct i2c) ); i2cConfig.pGBus = pGBus; i2cConfig.PioClock = 0; i2cConfig.PioData = 1; i2cConfig.RegBase = REG_BASE_system_block; i2cConfig.DelayUs = 0x8010; // for emi2c, this will use default, for i2c_hal, set to 10 // +10 for slow i2c bus memset(&vpcConfig, 0, sizeof(VPC323XD_CONFIG)); vpcConfig.pI2Cal_Context = (I2CAL_CONTEXT*) &i2cConfig; vpcConfig.uI2CAddress = VPC323XD_I2C_ADDR; vpcConfig.uVpcTimeoutMs = 10; if( argc > 1 ) { RMuint32 mode = 0; RMuint8 interactive = 0; RMuint8 a0; //VPC323XD_INPUT_PORT i; while( argi < argc ) { switch( argv[argi][0] ) { default: case 'h':_label_instructions: show_cmdline(argv[0]); argi = argi + 1; goto main_exit; break; case 'i': interactive = 1; argi = argi + 1; break; case 'a': // Address if( argc <= argi + 1) goto _label_instructions; a0 = strtol(argv[argi+1], NULL, 16) & 0xFF; vpcConfig.uI2CAddress = a0; MPRINT(("vpc assigned i2c address = 0x%x\n", vpcConfig.uI2CAddress)); argi = argi + 2; break; case 'c': if( argc <= argi + 1) goto _label_instructions; mode = strtol(argv[argi+1], NULL, 16); argi = argi + 2; break; } } switch( mode ) { case 0x760e1: case 0x760e1c2: case 0x760e1c3: case 0x760e1c4: MPRINT(("%lx configuration selected, vin 1\n", mode)); MPRINT(("---------------------------------\n")); MPRINT(("on board %lx, vpc323xd defaults to i2c address 0x%x\n", mode, vpcConfig.uI2CAddress)); if( RMFAILED(s = vpc323xd_detect(&vpcConfig)) ) { MPRINT(("vpc323xd_detect() RM_OK:%c, RM_NOT_FOUND:%c\n", (s == RM_OK)?'y':'n', (s == RM_NOT_FOUND)?'y':'n')); } else MPRINT(("vpc323xd_detect() detected\n")); vpcConfig.nVideoStandard = vpc323xd_vidstd_autodetect; s = vpc323xd_init(&vpcConfig); MPRINT(("init(autodetect standard), VIN1 composite = %d, RM_OK=%c\n", s, (s==RM_OK)?'y':'n')); { VPC323XD_INPUT_TYPE inputType = vpc323xd_intype_composite; VPC323XD_INPUT_PORT inputPort = vpc323xd_inport_vin1; MPRINT(("default VIN = 1\n")); switch( mode & 0xFF ) { case 0xc2: inputPort = vpc323xd_inport_vin2; MPRINT(("changed to VIN = 2\n")); break; case 0xc3: inputPort = vpc323xd_inport_vin3; MPRINT(("changed to VIN = 3\n")); break; case 0xc4: inputPort = vpc323xd_inport_vin4; MPRINT(("changed to VIN = 4\n")); break; } s = vpc323xd_select_input(&vpcConfig, inputType, inputPort); MPRINT(("vpc323xd_select_input(composite, VIN) = %d RM_OK=%c\n", s, (s==RM_OK)?'y':'n')); } break; // no mode case 0: MPRINT(("no board selected, NO INITIALIZATION!\n")); break; default: MPRINT(("%lx board not supported...\n", mode)); goto main_exit; break; } if( mode != 0 ) { RMuint32 index = 0; while ( index++ < 3 ) { VPC323XD_STDDETECT_STATUS sss = vpc323xd_stddet_none; s = vpc323xd_getStandardDetectStatus(&vpcConfig, &sss); MPRINT(("vpc323xd_getStandardDetectStatus() = %d RM_OK=%c\n", s, (s==RM_OK)?'y':'n')); switch( sss ) { case vpc323xd_stddet_switched: MPRINT(("detect = %d = standard switched\n", sss)); break; case vpc323xd_stddet_ok: MPRINT(("detect = %d = ok\n", sss)); break; case vpc323xd_stddet_nostart_noinput: MPRINT(("detect = %d = not started, no input\n", sss)); break; case vpc323xd_stddet_nostart_vertstd_notsupported: MPRINT(("detect = %d = not started. vertical standard not supported\n", sss)); break; case vpc323xd_stddet_nocolor: MPRINT(("detect = %d = no color\n", sss)); break; case vpc323xd_stddet_searching: MPRINT(("detect = %d = searching\n", sss)); break; case vpc323xd_stddet_failed_incorrect: MPRINT(("detect = %d = failed, incorrect standard\n", sss)); break; case vpc323xd_stddet_failed_notenabled: MPRINT(("detect = %d = failed, detected standard not enabled\n", sss)); break; default: MPRINT(("Bad status returned\n")); break; } mum_sleep(1); } } MPRINT(("%lx board initialization done\n", mode)); if ( interactive == 0 ) goto main_exit; } MPRINT(("Interactive Mode\n")); MPRINT(("----------------------------------------------\n")); show_commands(); // Prompt Application while(1) { MPRINT(("> ")); if( fgets(aBuffer, 255, stdin) != NULL ) { switch( aBuffer[0] ) { case 'D': s = vpc323xd_detect(&vpcConfig); MPRINT(("detect = %d, RM_OK=%c\n", s, (s==RM_OK)?'y':'n')); break; case 'I': switch(aBuffer[1]) { case 'a': vpcConfig.nVideoStandard = vpc323xd_vidstd_autodetect; s = vpc323xd_init(&vpcConfig); MPRINT(("init(autodetect standard), VIN1 composite = %d, RM_OK=%c\n", s, (s==RM_OK)?'y':'n')); break; case 'n': vpcConfig.nVideoStandard = vpc323xd_vidstd_ntscm; s = vpc323xd_init(&vpcConfig); MPRINT(("init(ntsc m), VIN1 composite = %d, RM_OK=%c\n", s, (s==RM_OK)?'y':'n')); break; default: MPRINT(("I - init\n")); MPRINT(("Ia - init autodetect\n")); MPRINT(("In - init ntsc\n")); break; } break; case 'S': { VPC323XD_INPUT_TYPE inputType; VPC323XD_INPUT_PORT inputPort = vpc323xd_inport_none; switch(aBuffer[1]) { // Component inputs case 'r': case 'y': if( aBuffer[1] == 'r' ) { inputType = vpc323xd_intype_component_rgb; MPRINT(("Input Type = Component RGB\n")); } else { inputType = vpc323xd_intype_component_yuv; MPRINT(("Input Type = Component YUV\n")); } switch( aBuffer[2] ) { case '1': inputPort = vpc323xd_inport_component1_vin4; MPRINT(("Component 1, Input Port = VIN4\n")); break; case '2': inputPort = vpc323xd_inport_component2_vin4; MPRINT(("Component 2, Input Port = VIN4\n")); break; default: MPRINT(("Input port for component VIN4, S[r/y][1/2] select 1 or 2\n")); break; } if( inputPort == vpc323xd_inport_none ) break; s = vpc323xd_select_input(&vpcConfig, inputType, inputPort); MPRINT(("vpc323xd_select_input() = %d RM_OK=%c\n", s, (s==RM_OK)?'y':'n')); break; // Composite/svideo inputs case 's': case 'c': if( aBuffer[1] == 's' ) { inputType = vpc323xd_intype_svideo; MPRINT(("Input Type = SVIDEO\n")); } else { inputType = vpc323xd_intype_composite; MPRINT(("Input Type = composite\n")); } switch( aBuffer[2] ) { case '1': inputPort = vpc323xd_inport_vin1; MPRINT(("Input Port = VIN1\n")); break; case '2': inputPort = vpc323xd_inport_vin2; MPRINT(("Input Port = VIN2\n")); break; case '3': inputPort = vpc323xd_inport_vin3; MPRINT(("Input Port = VIN3\n")); break; case '4': inputPort = vpc323xd_inport_vin4; MPRINT(("Input Port = VIN4\n")); break; default: MPRINT(("Input port for SVIDEO/composite, S[s/c][1/2/3/4]\n")); break; } if( inputPort == vpc323xd_inport_none ) break; s = vpc323xd_select_input(&vpcConfig, inputType, inputPort); MPRINT(("vpc323xd_select_input() = %d RM_OK=%c\n", s, (s==RM_OK)?'y':'n')); break; default: MPRINT(("S - select input\n")); MPRINT(("Sr - select rgb component\n")); MPRINT(("Sy - select yuv component\n")); MPRINT(("Sc - select composite\n")); MPRINT(("Ss - select svideo\n")); break; } } break; //Get status case 't': { VPC323XD_STDDETECT_STATUS sss = vpc323xd_stddet_none; s = vpc323xd_getStandardDetectStatus(&vpcConfig, &sss); MPRINT(("vpc323xd_getStandardDetectStatus() = %d RM_OK=%c\n", s, (s==RM_OK)?'y':'n')); switch( sss ) { case vpc323xd_stddet_switched: MPRINT(("detect = %d = standard switched\n", sss)); break; case vpc323xd_stddet_ok: MPRINT(("detect = %d = ok\n", sss)); break; case vpc323xd_stddet_nostart_noinput: MPRINT(("detect = %d = not started, no input\n", sss)); break; case vpc323xd_stddet_nostart_vertstd_notsupported: MPRINT(("detect = %d = not started. vertical standard not supported\n", sss)); break; case vpc323xd_stddet_nocolor: MPRINT(("detect = %d = no color\n", sss)); break; case vpc323xd_stddet_searching: MPRINT(("detect = %d = searching\n", sss)); break; case vpc323xd_stddet_failed_incorrect: MPRINT(("detect = %d = failed, incorrect standard\n", sss)); break; case vpc323xd_stddet_failed_notenabled: MPRINT(("detect = %d = failed, detected standard not enabled\n", sss)); break; default: MPRINT(("Bad status returned\n")); break; } } break; case 'q': goto main_exit; break; default: // print instructions show_commands(); break; } } } /* s = vpc323xd_select_input(&vpcConfig, vpc323xd_intype_composite, vpc323xd_inport_vin1); MPRINT(("select_input(760e1) = %d, RM_OK=%c\n", s, (s==RM_OK)?'y':'n'));*/main_exit: mum_exit(pGBus, pLLAD); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -