📄 tunerapp.c
字号:
/* * * tunerapp.c * * $Log: tunerapp.c,v $ * Revision 1.2 2006/01/22 00:32:26 bertrand * Ported contents of set_tron from dcc_2_branch to HEAD * * Revision 1.1.1.1.2.9 2005/06/23 11:23:15 michon * fixbuild * * Revision 1.1.1.1.2.7 2005/05/25 04:18:09 jpong * tunerapi-1.3.0 - change tuner mode using tunerapiOpen() without slow reinit. * * Revision 1.1.1.1.2.6 2005/05/18 05:18:17 jpong * tunerapp bug - strength/tune frequency moved out of signal status loop * tunerapi: - removed TunerApiProperty_DvbT_ChannelSpacing, now ALL have TunerApiProperty_ChannelSpacing * - generic_Scan added to internal functions * - generic_GetData_ChannelSpacing added to internal functions * * Revision 1.1.1.1.2.5 2005/05/17 02:53:34 jpong * fix for fq1216me, Correct procedure after reset * tunerapi now has GetProperty(Tunerapi_TuneFrequency) working * tunerapp example now has Signal Strength, and Tuned Frequency * * Revision 1.1.1.1.2.4 2005/04/20 22:37:31 jpong * new dvb-t properties * Tune() function instead of Set_Property(frequency). * scan should now include start frequency. * * Revision 1.1.1.1.2.3 2005/03/15 07:54:51 bertrand * Code does not depend on an existing set_rua_test directory (or symbolic * link thereof) at the parent of set_dtv anymore * * Revision 1.1.1.1.2.2 2005/03/15 07:38:50 bertrand * Code does not depend on an existing set_rua_test directory (or symbolic * link thereof) at the parent of set_dtv anymore * * Revision 1.1.1.1.2.1 2005/03/15 06:45:28 bertrand * Added missing standard header * * Revision 1.1.1.1 2005/03/10 00:06:00 bertrand * Initial import of the DTV specific code into the ndc repository * * Revision 1.5 2005/02/08 03:16:44 jpong * misc * * Revision 1.4 2004/12/22 02:37:08 jpong * auto dvb settings, incomplete new api * * Revision 1.3 2004/12/21 22:29:28 jpong * dvb channel locking * * Revision 1.2 2004/11/30 05:49:18 jpong * tunerapi addition : added property for low and high frequency of the tuner * tunerapp : shows exapmple of this addition * all: debug logging types fixed in DPRINT, _DEBUG = DEBUG * tuv1236d message fix * * Revision 1.1.1.1 2004/11/10 03:02:41 jpong * i2c devices * * * */#include <stdio.h>#include <stdlib.h>#include <string.h>#include <pthread.h> #/*include "../include/em_types.h"#include "../include/dmesg.h"#include "../emi2c/emi2c.h"#include "tuner.h"#define ALLOW_OS_CODE 1#include "rmdef/rmdef.h"#include "llad/include/gbus.h"#include "../helper/emhelper.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 "../emi2c/emi2c.h"#include "./tunerapi/tunerapi.h"#define APP_VERSION "tunerapp-1.3"#define MAX_TUNERS 10RMuint32 tableAtscVHF [] = { 0, 0, /* no 0, 1 */ 57000000, 63000000, 69000000, 79000000, 85000000, /* Low VHF 2-6 */ 177000000, 183000000, 189000000, 195000000, 201000000, 207000000, 213000000 /* Hi VHF 7-13 */};RMuint32 tableNtscMVHF [] = { 0, 0, /* no 0, 1 */ 55250000, 61250000, 67250000, 77250000, 83250000, /* Low VHF 2-6 */ 175250000, 181250000, 187250000, 193250000, 199250000, 205250000, 211250000 /*125 Hi VHF 7-13 */};RMvoid show_commands(void);RMvoid show_cmdline(char* appname);int main(int argc, char* argv[]){ int argi = 1; char aBuffer[255]; struct llad* pLLAD; RMvoid *pGBus; TUNERAPI_CONTEXT listTunerContext[MAX_TUNERS]; RMint32 nTuners = 0; struct i2c i2cConfig; RMuint32 initialFrequency = 0; RMstatus r; RMint8 selectedTuner = -1; RMbool closeTunerOnExit = TRUE; RMbool interactive = FALSE; printf("\n"); printf("Sigma Designs Tuner Application "); printf(APP_VERSION); printf(" (c) 2003\n"); printf("----------------------------------------------\n"); // the context needs to be 0 to start so that it is not a re-open memset( listTunerContext, 0, sizeof(TUNERAPI_CONTEXT) * MAX_TUNERS); if( (r = mum_init( 0, &pLLAD, &pGBus)) != RM_OK ) { MPRINT(("main !mum_init FAILED %d\ncheck your 86xx driver\n", r)); exit(r); } /* 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 = 0x800f; // for emi2c, this will use default, for i2c_hal, set to 10 // +10 for slow i2c bus // Cmd line only quit! section if( argc <= 1 ) { show_cmdline(argv[0]); goto main_exit; } else { TUNERAPI_CFG tunerapiCfg; TUNERAPI_PROPERTY_DATA_U pd_U; RMuint32 uStart = 0; RMuint32 uEnd = 0; memset(&tunerapiCfg, 0, sizeof(TUNERAPI_CFG)); tunerapiCfg.pI2Cal_Context = (TUNERAPI_CONTEXT*) &i2cConfig; tunerapiCfg.nTunerInput = TunerInput_First; while( argi < argc ) { //RMuint32 addx; switch( argv[argi][0] ) {_label_instructions: default: case 'H': show_cmdline(argv[0]); goto main_exit; break; case 'T': if( argc <= argi + 1) goto _label_instructions; switch (argv[argi+1][0]) { case '1': tunerapiCfg.nTunerModel = TunerModel_Philips_TUV1236D; if( (tunerapiCfg.I2CAddress[0] == 0) && (tunerapiCfg.I2CAddress[1] == 0) ) { tunerapiCfg.I2CAddress[0] = 0x14; tunerapiCfg.I2CAddress[1] = 0x16; printf("default i2c addresses 0x%x, 0x%x\n", tunerapiCfg.I2CAddress[0], tunerapiCfg.I2CAddress[1]); } printf("*Philips TUV1236D Tuner selected\n"); break; case '2': tunerapiCfg.nTunerModel = TunerModel_Philips_FQ1216ME; if( (tunerapiCfg.I2CAddress[0] == 0) && (tunerapiCfg.I2CAddress[1] == 0) ) { tunerapiCfg.I2CAddress[0] = 0x86; tunerapiCfg.I2CAddress[1] = 0xC2; printf("default i2c addresses 0x%x, 0x%x\n", tunerapiCfg.I2CAddress[0], tunerapiCfg.I2CAddress[1]); } printf("*Philips FQ1216ME Tuner selected\n"); break; case '3': tunerapiCfg.nTunerModel = TunerModel_Philips_TU1216; if( (tunerapiCfg.I2CAddress[0] == 0) && (tunerapiCfg.I2CAddress[1] == 0) ) { tunerapiCfg.I2CAddress[0] = 0x10; tunerapiCfg.I2CAddress[1] = 0xC0; printf("default i2c addresses 0x%x, 0x%x\n", tunerapiCfg.I2CAddress[0], tunerapiCfg.I2CAddress[1]); } printf("*Philips TU1216 Tuner selected\n"); break; default: goto _label_instructions; break; } argi = argi + 2; break; case 'M': if( argc <= argi + 1) goto _label_instructions; switch (argv[argi+1][0]) { case 'b': tunerapiCfg.nTunerMode = TunerMode_Analog_tvBG; printf("*Mode Analog tvBG selected\n"); break; case 'i': tunerapiCfg.nTunerMode = TunerMode_Analog_tvI; printf("*Mode Analog tvI selected\n"); break; case 'd': tunerapiCfg.nTunerMode = TunerMode_Analog_tvDK; printf("*Mode Analog tvDK selected\n"); break; case 'l': tunerapiCfg.nTunerMode = TunerMode_Analog_tvL; printf("*Mode Analog tvL selected\n"); break; case '1': tunerapiCfg.nTunerMode = TunerMode_Analog_tvL1; printf("*Mode Analog tvL1 selected\n"); break; case 'm': tunerapiCfg.nTunerMode = TunerMode_Analog_tvM; printf("*Mode Analog tvM selected\n"); break; case 'j': tunerapiCfg.nTunerMode = TunerMode_Analog_tvMJapan; printf("*Mode Analog tvM Japan selected\n"); break; case 'p': tunerapiCfg.nTunerMode = TunerMode_Atsc_Parallel; printf("*Mode Atsc Parallel selected\n"); break; case 's': tunerapiCfg.nTunerMode = TunerMode_Atsc_Serial; printf("*Mode Atsc Serial selected\n"); break; case 't': tunerapiCfg.nTunerMode = TunerMode_DvbT_Parallel; printf("*Mode Dvb-T parallel selected\n"); break; case 'u': tunerapiCfg.nTunerMode = TunerMode_DvbT_Serial; printf("*Mode Dvb-T Serial selected\n"); break; default: goto _label_instructions; break; } argi = argi + 2; break; case 'C': // Channel if( argc <= argi + 1) goto _label_instructions; initialFrequency = strtol(argv[argi+1], NULL, 10); argi = argi + 2; break; case 'A': if( argc <= argi + 2) goto _label_instructions; tunerapiCfg.I2CAddress[0] = strtol(argv[argi+1], NULL, 16) & 0xFF; tunerapiCfg.I2CAddress[1] = strtol(argv[argi+2], NULL, 16) & 0xFF; argi = argi + 3; break; case 'S': if( argc <= argi + 2)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -