コード例 #1
0
ファイル: am_si_test.c プロジェクト: felipemogollon/dvb
int main(int argc, char **argv)
{
	AM_DMX_OpenPara_t para;
	AM_FEND_OpenPara_t fpara;
	struct dvb_frontend_parameters p;
	fe_status_t status;
	int freq = 0;
	
	memset(&fpara, 0, sizeof(fpara));
	AM_TRY(AM_FEND_Open(FEND_DEV_NO, &fpara));
	
	if(argc>1)
	{
		sscanf(argv[1], "%d", &freq);
	}
	
	if(!freq)
	{
		freq = 618000;
	}
	
	p.frequency = freq;
	p.u.qam.symbol_rate = 6875*1000;
	p.u.qam.modulation = QAM_64;
	p.u.qam.fec_inner = FEC_AUTO;

	printf("Try lock %d MHz...\n", p.frequency/1000);
	//sleep(1);
	AM_TRY(AM_FEND_Lock(FEND_DEV_NO, &p, &status));
	
	if(status&FE_HAS_LOCK)
	{
		printf("locked\n");
	}
	else
	{
		printf("unlocked, there will be no sections received\n");
	}
	
	memset(&para, 0, sizeof(para));
	AM_TRY(AM_DMX_Open(DMX_DEV_NO, &para));
	
	start_si_test();
	
	AM_DMX_Close(DMX_DEV_NO);
	AM_FEND_Close(FEND_DEV_NO);
	
	return 0;
}
コード例 #2
0
ファイル: am_cfg_input.c プロジェクト: felipemogollon/dvb
/**\brief 将一个字符放入缓冲区*/
static AM_INLINE AM_ErrorCode_t cfg_putc (AM_CFG_Parser_t *parser, char ch)
{
	AM_TRY(cfg_resize_buffer(parser, parser->leng+1));
	
	parser->buffer[parser->leng++]=ch;
	return AM_SUCCESS;
}
コード例 #3
0
ファイル: ctisc.c プロジェクト: sguotao/TestAfinal
void SC_SetParam()
{
	AM_SMC_Param_t SMCpara;
	AM_TRY(AM_SMC_GetParam(g_u8SCIPort, &SMCpara));
#if 0	
	 printf("[zshang_old]\n SMCpara.f[%d]\n SMCpara.d[%d]\n SMCpara.n[%d]\n SMCpara.bwi[%d]\n SMCpara.cwi[%d]\n SMCpara.bgt[%d]\n SMCpara.freq[%d]\n SMCpara.recv_invert[%d]\n SMCpara.recv_lsb_msb[%d]\n SMCpara.recv_no_parity[%d]\n SMCpara.xmit_invert[%d]\n SMCpara.xmit_lsb_msb[%d]\n SMCpara.xmit_retries[%d]\n SMCpara.xmit_repeat_dis[%d]\n", 
	 SMCpara.f,
	 SMCpara.d,
	 SMCpara.n,
	 SMCpara.bwi,
	 SMCpara.cwi,
	 SMCpara.bgt,
	 SMCpara.freq,
	 SMCpara.recv_invert,
	 SMCpara.recv_lsb_msb,
	 SMCpara.recv_no_parity,
	 SMCpara.xmit_invert,
	 SMCpara.xmit_lsb_msb,
	 SMCpara.xmit_retries,
	 SMCpara.xmit_repeat_dis);
#endif	 
	SMCpara.freq = 6000;
	SMCpara.bwi = 4;
	SMCpara.cwi =5;
	
	AM_TRY(AM_SMC_SetParam(g_u8SCIPort, &SMCpara));
#if 0	
	AM_TRY(AM_SMC_GetParam(g_u8SCIPort, &SMCpara));
	printf("[zshang_new]\n SMCpara.f[%d]\n SMCpara.d[%d]\n SMCpara.n[%d]\n SMCpara.bwi[%d]\n SMCpara.cwi[%d]\n SMCpara.bgt[%d]\n SMCpara.freq[%d]\n SMCpara.recv_invert[%d]\n SMCpara.recv_lsb_msb[%d]\n SMCpara.recv_no_parity[%d]\n SMCpara.xmit_invert[%d]\n SMCpara.xmit_lsb_msb[%d]\n SMCpara.xmit_retries[%d]\n SMCpara.xmit_repeat_dis[%d]\n", 
	 SMCpara.f,
	 SMCpara.d,
	 SMCpara.n,
	 SMCpara.bwi,
	 SMCpara.cwi,
	 SMCpara.bgt,
	 SMCpara.freq,
	 SMCpara.recv_invert,
	 SMCpara.recv_lsb_msb,
	 SMCpara.recv_no_parity,
	 SMCpara.xmit_invert,
	 SMCpara.xmit_lsb_msb,
	 SMCpara.xmit_retries,
	 SMCpara.xmit_repeat_dis);
#endif	
}
コード例 #4
0
ファイル: am_osd.c プロジェクト: felipemogollon/dvb
/**\brief 取得OSD设备的显示绘图表面,如果OSD没有使用双缓冲,则返回的Surface和AM_OSD_GetSurface的返回值相同
 * \param dev_no OSD设备号
 * \param[out] s 返回OSD绘图表面
 * \return
 *   - AM_SUCCESS 成功
 *   - 其他值 错误代码(见am_osd.h)
 */
AM_ErrorCode_t AM_OSD_GetDisplaySurface(int dev_no, AM_OSD_Surface_t **s)
{
	AM_OSD_Device_t *dev;
	
	assert(s);
	
	AM_TRY(osd_get_openned_dev(dev_no, &dev));
	
	*s = dev->display;
	return AM_SUCCESS;
}
コード例 #5
0
ファイル: am_vout.c プロジェクト: felipemogollon/dvb
/**\brief 根据设备号取得设备结构并检查设备是否已经打开*/
static AM_INLINE AM_ErrorCode_t vout_get_openned_dev(int dev_no, AM_VOUT_Device_t **dev)
{
	AM_TRY(vout_get_dev(dev_no, dev));
	
	if(!(*dev)->openned)
	{
		AM_DEBUG(1, "vout device %d has not been openned", dev_no);
		return AM_VOUT_ERR_INVALID_DEV_NO;
	}
	
	return AM_SUCCESS;
}
コード例 #6
0
ファイル: am_cfg_input.c プロジェクト: felipemogollon/dvb
static AM_ErrorCode_t cfg_parse (AM_CFG_Parser_t *parser)
{
	int end = 0;
	
	do
	{
		AM_TRY(cfg_read_line(parser, &end));
	}
	while(!end);
	
	return AM_SUCCESS;
}
コード例 #7
0
ファイル: am_dmx.c プロジェクト: takitr/dvb
/**\brief 根据设备号取得设备结构并检查设备是否已经打开*/
static AM_INLINE AM_ErrorCode_t dmx_get_openned_dev(int dev_no, AM_DMX_Device_t **dev)
{
    AM_TRY(dmx_get_dev(dev_no, dev));

    if((*dev)->open_count <= 0)
    {
        AM_DEBUG(1, "demux device %d has not been openned", dev_no);
        return AM_DMX_ERR_INVALID_DEV_NO;
    }

    return AM_SUCCESS;
}
コード例 #8
0
/**\brief 根据设备号取得设备结构并检查设备是否已经打开*/
static AM_INLINE AM_ErrorCode_t fend_get_openned_dev(int dev_no, AM_FEND_Device_t **dev)
{
	AM_TRY(fend_get_dev(dev_no, dev));
	
	if(!(*dev)->openned)
	{
		AM_DEBUG(1, "frontend device %d has not been openned", dev_no);
		return AM_FEND_ERR_INVALID_DEV_NO;
	}
	
	return AM_SUCCESS;
}
コード例 #9
0
ファイル: am_cfg_input.c プロジェクト: felipemogollon/dvb
/**\brief 取得缓冲区中的字符串指针*/
static AM_INLINE AM_ErrorCode_t cfg_get_str (AM_CFG_Parser_t *parser, int begin, const char **pstr)
{
	if(parser->leng==begin)
	{
		*pstr = NULL;
		return AM_SUCCESS;
	}
	
	AM_TRY(cfg_putc(parser, 0));
	
	*pstr = parser->buffer+begin;
	return AM_SUCCESS;
}
コード例 #10
0
ファイル: am_osd.c プロジェクト: felipemogollon/dvb
/**\brief 打开一个OSD设备
 * \param dev_no OSD设备号
 * \param[in] para 设备开启参数
 * \return
 *   - AM_SUCCESS 成功
 *   - 其他值 错误代码(见am_osd.h)
 */
AM_ErrorCode_t AM_OSD_Open(int dev_no, AM_OSD_OpenPara_t *para)
{
	AM_OSD_Device_t *dev;
	AM_ErrorCode_t ret = AM_SUCCESS;
	
	assert(para);
	
	AM_TRY(osd_get_dev(dev_no, &dev));
	
	pthread_mutex_lock(&am_gAdpLock);
	
	/*Initialize the global data*/
	osd_init();
	
	if(dev->openned)
	{
		AM_DEBUG(1, "osd device already openned");
		ret = AM_OSD_ERR_BUSY;
		osd_deinit();
	}
	
	dev->dev_no      = dev_no;
	dev->vout_dev_no = para->vout_dev_no;
	dev->surface     = NULL;
	dev->display     = NULL;
	dev->enable      = AM_TRUE;
	
	if(ret==AM_SUCCESS)
	{
		dev->dev_no = dev_no;
		
		if(dev->drv->open)
		{
			ret = dev->drv->open(dev, para, &dev->surface, &dev->display);
			if(ret!=AM_SUCCESS)
				osd_deinit();
		}
	}
	
	if(ret==AM_SUCCESS)
	{
		dev->openned = AM_TRUE;
		dev->para    = *para;
		dev->enable_double_buffer = para->enable_double_buffer;
	}
	
	pthread_mutex_unlock(&am_gAdpLock);
	
	return ret;
}
コード例 #11
0
ファイル: am_db_test.c プロジェクト: takitr/dvb
int main(int argc, char **argv)
{
    sqlite3 *pdb;
    int go = 1;
    int rc;
    char buf[256];
    char *errmsg;
    int (*cb)(void*, int, char**, char**);

    AM_TRY(AM_DB_Init(&pdb));
    sqlite3_exec(pdb, "insert into net_table(name, network_id) values('network1', '1111')", NULL, NULL, &errmsg);
    sqlite3_exec(pdb, "insert into net_table(name, network_id) values('network2', '1112')", NULL, NULL, &errmsg);
    sqlite3_exec(pdb, "insert into net_table(name, network_id) values('network3', '1113')", NULL, NULL, &errmsg);
    sqlite3_exec(pdb, "insert into ts_table(db_net_id, ts_id, freq) values('2', '100', '474000000')", NULL, NULL, &errmsg);

    do {
        printf("Enter your sql cmd:\n");
        if (gets(buf))
        {
            cb = NULL;
            if (!strncmp(buf, "select", 6))
            {
                cb = print_result_callback;
            }
            else if (!strncmp(buf, "dbselect", 8))
            {
                dbselect_test(pdb);
                continue;
            }
            else if (!strncmp(buf, "quit", 4))
            {
                go=0;
                break;
            }

            if (sqlite3_exec(pdb, buf, cb, NULL, &errmsg) != SQLITE_OK)
            {
                printf("Opration failed, reseaon[%s]\n", errmsg);
            }
            else
            {
                printf("Operation OK!\n\n");
            }
        }
    } while (go);

    AM_DB_Quit(pdb);

    return 0;
}
コード例 #12
0
ファイル: am_fend.c プロジェクト: felipemogollon/dvb
/**\brief Sets the start frequency and stop frequency.*/
static AM_ErrorCode_t  AM_FEND_IBlindScanAPI_SetFreqRange(int dev_no, unsigned int StartFreq_KHz, unsigned int EndFreq_KHz)
{	
	AM_FEND_Device_t *dev;
	AM_ErrorCode_t ret = AM_SUCCESS;
	
	AM_TRY(fend_get_openned_dev(dev_no, &dev));
	
	pthread_mutex_lock(&dev->lock);

	dev->bs_setting.bsPara.minfrequency = StartFreq_KHz;		/*Change default start frequency*/
	dev->bs_setting.bsPara.maxfrequency = EndFreq_KHz;			/*Change default end frequency*/

	pthread_mutex_unlock(&dev->lock);
	
	return ret;
}
コード例 #13
0
/**\brief 打开一个DVB前端设备
 * \param dev_no 前端设备号
 * \param[in] para 设备开启参数
 * \return
 *   - AM_SUCCESS 成功
 *   - 其他值 错误代码(见am_fend.h)
 */
AM_ErrorCode_t AM_FEND_Open(int dev_no, const AM_FEND_OpenPara_t *para)
{
	AM_FEND_Device_t *dev;
	AM_ErrorCode_t ret = AM_SUCCESS;
	int rc;
	
	AM_TRY(fend_get_dev(dev_no, &dev));
#if 1	
	pthread_mutex_lock(&am_gAdpLock);
	
	if(dev->openned)
	{
		AM_DEBUG(1, "frontend device %d has already been openned", dev_no);
		ret = AM_FEND_ERR_BUSY;
		goto final;
	}
コード例 #14
0
ファイル: am_fend.c プロジェクト: felipemogollon/dvb
/**\brief Gets the progress of blind scan process based on current scan step's start frequency.*/
static unsigned short AM_FEND_IBlindscanAPI_GetProgress(int dev_no)
{
	AM_FEND_Device_t *dev = NULL;
	AM_ErrorCode_t ret = AM_SUCCESS;
	unsigned short process = 0;
		
	AM_TRY(fend_get_openned_dev(dev_no, &dev));

	pthread_mutex_lock(&dev->lock);

	process = dev->bs_setting.bsEvent.u.m_uiprogress;

	pthread_mutex_unlock(&dev->lock);
	
	return process;
}
コード例 #15
0
ファイル: am_vout.c プロジェクト: felipemogollon/dvb
/**\brief 打开视频输出设备
 * \param dev_no 视频输出设备号
 * \param[in] para 视频输出设备开启参数
 * \return
 *   - AM_SUCCESS 成功
 *   - 其他值 错误代码(见am_vout.h)
 */
AM_ErrorCode_t AM_VOUT_Open(int dev_no, const AM_VOUT_OpenPara_t *para)
{
	AM_VOUT_Device_t *dev;
	AM_ErrorCode_t ret = AM_SUCCESS;
	
	assert(para);
	
	AM_TRY(vout_get_dev(dev_no, &dev));
	
	pthread_mutex_lock(&am_gAdpLock);
	
	if(dev->openned)
	{
		AM_DEBUG(1, "vout device %d has already been openned", dev_no);
		ret = AM_VOUT_ERR_BUSY;
		goto final;
	}
コード例 #16
0
ファイル: am_dmx.c プロジェクト: takitr/dvb
/**\brief 打开解复用设备
 * \param dev_no 解复用设备号
 * \param[in] para 解复用设备开启参数
 * \return
 *   - AM_SUCCESS 成功
 *   - 其他值 错误代码(见am_dmx.h)
 */
AM_ErrorCode_t AM_DMX_Open(int dev_no, const AM_DMX_OpenPara_t *para)
{
    AM_DMX_Device_t *dev;
    AM_ErrorCode_t ret = AM_SUCCESS;

    assert(para);

    AM_TRY(dmx_get_dev(dev_no, &dev));

    pthread_mutex_lock(&am_gAdpLock);

    if(dev->open_count > 0)
    {
        AM_DEBUG(1, "demux device %d has already been openned", dev_no);
        dev->open_count++;
        ret = AM_SUCCESS;
        goto final;
    }
コード例 #17
0
ファイル: am_fend.c プロジェクト: felipemogollon/dvb
/**\brief Queries the blind scan event.*/
static AM_ErrorCode_t  AM_FEND_IBlindScanAPI_GetScanEvent(int dev_no, struct dvbsx_blindscanevent *pbsevent)
{
	AM_FEND_Device_t *dev = NULL;
	AM_ErrorCode_t ret = AM_SUCCESS;
	
	AM_TRY(fend_get_openned_dev(dev_no, &dev));
	
	if(!dev->drv->blindscan_getscanevent)
	{
		AM_DEBUG(1, "fronend %d no not support dvbsx_blindscan_getscanevent", dev_no);
		return AM_FEND_ERR_NOT_SUPPORTED;
	}

	pthread_mutex_lock(&dev->lock);

	struct dvbsx_blindscanevent * pbsEvent = &(dev->bs_setting.bsEvent);	

	/*Query the internal blind scan procedure information.*/
	ret = dev->drv->blindscan_getscanevent(dev, pbsEvent);
	if(ret != AM_SUCCESS)
	{
		ret = AM_FEND_ERR_BLINDSCAN;
		pthread_mutex_unlock(&dev->lock);
		return ret;
	}

	memcpy(pbsevent, pbsEvent, sizeof(struct dvbsx_blindscanevent));

	/*update tp info*/
	if(pbsEvent->status == BLINDSCAN_UPDATERESULTFREQ)
	{
		/*now driver return 1 tp*/
		dev->bs_setting.m_uiChannelCount = dev->bs_setting.m_uiChannelCount + 1;	

		memcpy(&(dev->bs_setting.channels[dev->bs_setting.m_uiChannelCount - 1]), 
				&(pbsEvent->u.parameters), sizeof(struct dvb_frontend_parameters));
	}

	pthread_mutex_unlock(&dev->lock);
	
	return ret;
}
コード例 #18
0
ファイル: am_osd.c プロジェクト: felipemogollon/dvb
/**\brief 设定OSD的全局Alpha值
 * \param dev_no OSD设备号
 * \param alpha Alpha值(0~255)
 * \return
 *   - AM_SUCCESS 成功
 *   - 其他值 错误代码(见am_osd.h)
 */
AM_ErrorCode_t AM_OSD_SetGlobalAlpha(int dev_no, uint8_t alpha)
{
	AM_OSD_Device_t *dev;
	AM_ErrorCode_t ret = AM_SUCCESS;
		
	AM_TRY(osd_get_openned_dev(dev_no, &dev));
	
	if(!dev->drv->set_alpha)
	{
		AM_DEBUG(1, "do not support set_alpha");
		ret = AM_OSD_ERR_NOT_SUPPORTED;
	}
	
	if(ret==AM_SUCCESS)
	{
		ret = dev->drv->set_alpha(dev, alpha);
	}
	
	return ret;
}
コード例 #19
0
ファイル: am_cfg_input.c プロジェクト: felipemogollon/dvb
/**\brief 将一个section压入section栈*/
static AM_ErrorCode_t cfg_push_sec (AM_CFG_Parser_t *parser)
{
	AM_CFG_SecStack_t *sec;
	const char *name;
	
	AM_TRY(cfg_get_str(parser, 0, &name));
	
	sec = AM_MEM_ALLOC_TYPE0(AM_CFG_SecStack_t);
	if(!sec)
		return AM_CFG_ERR_NO_MEM;
	
	sec->name = AM_MEM_Strdup(name);
	if(!sec->name)
		return AM_CFG_ERR_NO_MEM;
	
	sec->bottom = parser->sec_stack;
	parser->sec_stack = sec;
	
	return AM_SUCCESS;
}
コード例 #20
0
ファイル: am_osd.c プロジェクト: felipemogollon/dvb
/**\brief 关闭一个OSD设备
 * \param dev_no OSD设备号
 * \return
 *   - AM_SUCCESS 成功
 *   - 其他值 错误代码(见am_osd.h)
 */
AM_ErrorCode_t AM_OSD_Close(int dev_no)
{
	AM_OSD_Device_t *dev;
	
	AM_TRY(osd_get_openned_dev(dev_no, &dev));
	
	pthread_mutex_lock(&am_gAdpLock);
	
	if(dev->drv->close)
	{
		dev->drv->close(dev);
	}
	
	dev->openned = AM_FALSE;
	osd_deinit();
	
	pthread_mutex_unlock(&am_gAdpLock);
	
	return AM_SUCCESS;
}
コード例 #21
0
ファイル: am_osd.c プロジェクト: felipemogollon/dvb
/**\brief 不显示OSD层
 * \param dev_no OSD设备号
 * \return
 *   - AM_SUCCESS 成功
 *   - 其他值 错误代码(见am_osd.h)
 */
AM_ErrorCode_t AM_OSD_Disable(int dev_no)
{
	AM_OSD_Device_t *dev;
	AM_ErrorCode_t ret = AM_SUCCESS;
	
	AM_TRY(osd_get_openned_dev(dev_no, &dev));
	
	if(!dev->drv->enable)
	{
		AM_DEBUG(1, "do not support enable");
		ret = AM_OSD_ERR_NOT_SUPPORTED;
	}
	
	ret = dev->drv->enable(dev, AM_FALSE);
	if(ret==AM_SUCCESS)
	{
		dev->enable = AM_FALSE;
	}
	
	return ret;
}
コード例 #22
0
ファイル: am_fend.c プロジェクト: felipemogollon/dvb
/**\brief Initializes the blind scan parameters.*/
static AM_ErrorCode_t AM_FEND_IBlindScanAPI_Initialize(int dev_no)
{
	AM_FEND_Device_t *dev;
	AM_ErrorCode_t ret = AM_SUCCESS;
	
	AM_TRY(fend_get_openned_dev(dev_no, &dev));
	
	pthread_mutex_lock(&dev->lock);

	memset(&(dev->bs_setting), 0, sizeof(struct AM_FEND_DVBSx_BlindScanAPI_Setting));

	dev->bs_setting.bsPara.minfrequency = M_BS_START_FREQ * 1000;		/*Default Set Blind scan start frequency*/
	dev->bs_setting.bsPara.maxfrequency = M_BS_STOP_FREQ * 1000;		/*Default Set Blind scan stop frequency*/

	dev->bs_setting.bsPara.maxSymbolRate = M_BS_MAX_SYMB * 1000 * 1000;  /*Set MAX symbol rate*/
	dev->bs_setting.bsPara.minSymbolRate = M_BS_MIN_SYMB * 1000 * 1000;   /*Set MIN symbol rate*/

	dev->bs_setting.bsPara.timeout = FEND_WAIT_TIMEOUT;

	pthread_mutex_unlock(&dev->lock);
	
	return ret;
}
コード例 #23
0
ファイル: am_fend.c プロジェクト: felipemogollon/dvb
static AM_ErrorCode_t AM_FEND_BlindDump(int dev_no)
{
	AM_FEND_Device_t *dev = NULL;
	AM_ErrorCode_t ret = AM_SUCCESS;
	int i = 0;

	AM_TRY(fend_get_openned_dev(dev_no, &dev));

	AM_DEBUG(1, "AM_FEND_BlindDump start %d--------------------\n", dev->bs_setting.m_uiChannelCount);

	pthread_mutex_lock(&dev->lock);

	for(i = 0; i < (dev->bs_setting.m_uiChannelCount); i++)
	{
		AM_DEBUG(1, "num:%d freq:%d symb:%d\n", i, dev->bs_setting.channels[i].frequency, dev->bs_setting.channels[i].u.qpsk.symbol_rate);
	}

	pthread_mutex_unlock(&dev->lock);	

	AM_DEBUG(1, "AM_FEND_BlindDump end--------------------\n");

	return ret;
}
コード例 #24
0
ファイル: am_osd.c プロジェクト: felipemogollon/dvb
/**\brief 双缓冲模式下,将缓冲区中的数据显示到OSD中
 * \param dev_no OSD设备号
 * \param[in] rect 要刷新的区域,NULL表示整个OSD
 * \return
 *   - AM_SUCCESS 成功
 *   - 其他值 错误代码(见am_osd.h)
 */
AM_ErrorCode_t AM_OSD_Update(int dev_no, AM_OSD_Rect_t *rect)
{
	AM_OSD_Device_t *dev;
		
	AM_TRY(osd_get_openned_dev(dev_no, &dev));
	
	if(dev->drv->update)
	{
		AM_OSD_Rect_t ur;
		
		if(!rect)
		{
			rect = &ur;
			ur.x = 0;
			ur.y = 0;
			ur.w = dev->surface->width;
			ur.h = dev->surface->height;
		}
		
		dev->drv->update(dev, rect);
	}
	
	return AM_SUCCESS;
}
コード例 #25
0
ファイル: am_fend.c プロジェクト: felipemogollon/dvb
/**\brief Stops blind scan process.*/
static AM_ErrorCode_t  AM_FEND_IBlindScanAPI_Exit(int dev_no)
{
	AM_FEND_Device_t *dev = NULL;
	AM_ErrorCode_t ret = AM_SUCCESS;
	
	AM_TRY(fend_get_openned_dev(dev_no, &dev));
	
	if(!dev->drv->blindscan_cancel)
	{
		AM_DEBUG(1, "fronend %d no not support blindscan_cancel", dev_no);
		return AM_FEND_ERR_NOT_SUPPORTED;
	}	

	pthread_mutex_lock(&dev->lock);
	
	/*driver need to set in demod mode*/
	ret = dev->drv->blindscan_cancel(dev);

	usleep(10 * 1000);
	
	pthread_mutex_unlock(&dev->lock);

	return ret;	
}
コード例 #26
0
ファイル: am_cfg_input.c プロジェクト: felipemogollon/dvb
/**\brief 从输入文件中读取一行数据*/
static AM_ErrorCode_t cfg_read_line (AM_CFG_Parser_t *parser, int *pend)
{
	int ch, leng;
	const char *key, *value;
	
	/*Clear the buffer*/
	parser->leng = 0;
	
	/*Eatup space*/
	do
	{
		AM_TRY(cfg_getc(parser, &ch));
	}
	while((ch!=EOF) && isspace(ch));
	
	if(ch==EOF)
	{
		*pend = 1;
		return AM_SUCCESS;
	}
	
	/*Section结束标志*/
	if(ch=='}')
	{
		if(!parser->sec_stack)
		{
			AM_DEBUG(1, "\'{\' mismatch");
			cfg_error(parser);
			return AM_CFG_ERR_SYNTAX;
		}
		
		if (parser->sec_end_cb)
		{
			const char *sec_name = parser->sec_stack->name;
			AM_TRY(parser->sec_end_cb(parser->user_data, sec_name?sec_name:""));
		}
		cfg_pop_sec(parser);
		return AM_SUCCESS;
	}
	else
	{
		/*读取名字*/
		while((ch!=EOF) && (ch!='=') && (ch!='{') && (ch!='#') && (ch!='\n'))
		{
			AM_TRY(cfg_putc(parser, ch));
			AM_TRY(cfg_getc(parser, &ch));
		}
	
		/*Section开始*/
		if(ch=='{')
		{
			AM_TRY(cfg_push_sec(parser));
			if(parser->sec_begin_cb)
			{
				const char *sec_name = parser->sec_stack->name;
				AM_TRY(parser->sec_begin_cb(parser->user_data, sec_name?sec_name:""));
			}
			return AM_SUCCESS;
		}
	
		/*去除键名末尾的空格*/
		leng = parser->leng;
	
		while((leng>0) && isspace(parser->buffer[leng-1]))
		{
			leng--;
		}
		parser->leng = leng;
	
		/*得到键名*/
		AM_TRY(cfg_get_str(parser, 0, &key));
	
		/*读取键值*/
		if(ch=='=')
		{
			int vpos, quot;
		
			/*清除空格/TAB*/
			do
			{
				AM_TRY(cfg_getc(parser, &ch));
			}
			while((ch!=EOF) && isspace(ch) && (ch!='\n'));
		
			vpos = parser->leng;
			quot = (ch=='\"')?AM_TRUE:AM_FALSE;
			if(quot)
			{
				while(1)
				{
					AM_TRY(cfg_getc(parser, &ch));
					if((ch==EOF)||(ch=='\n')) break;
					if(ch=='\\')
					{
						AM_TRY(cfg_getc(parser, &ch));
						if(ch==EOF) break;
						switch(ch)
						{
							case 'n':
								ch='\n';
							break;
							case 'r':
								ch='\r';
							break;
							case 't':
								ch='\t';
							break;
							case 'v':
								ch='\v';
							break;
							case 'f':
								ch='\f';
							break;
							case 'a':
								ch='\a';
							break;
							case 'b':
								ch='\b';
							break;
							case '\n':
								AM_TRY(cfg_getc(parser, &ch));
								if((ch==EOF)||(ch=='\n')) break;
							break;
							default:
							break;
						}
					}
				
					AM_TRY(cfg_putc(parser, ch));
				}
			}
			else
			{
				do
				{
					AM_TRY(cfg_putc(parser, ch));
					AM_TRY(cfg_getc(parser, &ch));
				}
				while((ch!=EOF) && (ch!='\n'));
			}
		
			/*去除键名末尾的空格*/
			leng = parser->leng;
		
			while((leng>vpos) && isspace(parser->buffer[leng-1]))
			{
				leng--;
			}
			parser->leng = leng;
		
			if (quot && (parser->buffer[leng-1]!='\"'))
			{
				AM_DEBUG(1, "\'\"\' mismatch");
				cfg_error(parser);
				return AM_CFG_ERR_SYNTAX;
			}
		
			if (quot) parser->leng--;
			AM_TRY(cfg_get_str(parser, vpos, &value));
		}
		else
		{
			value=NULL;
		}
	
		if ((key || value) && parser->key_cb)
		{
			AM_TRY(parser->key_cb(parser->user_data, key?key:"", value?value:""));
		}
	}
	
	/*Eatup comment*/
	while((ch!='\n') && (ch!=EOF))
	{
		AM_TRY(cfg_getc(parser, &ch));
	}
	
	if (ch==EOF) {
		*pend = 1;
	}
	
	return AM_SUCCESS;
}
コード例 #27
0
ファイル: am_dmx_test.c プロジェクト: felipemogollon/dvb
static int setlayer(int layer/*1/2/4/7*/)
{
	AM_ErrorCode_t ret;

	struct dtv_property p = {.cmd=DTV_ISDBT_LAYER_ENABLED, .u.data = layer};
	struct dtv_properties props = {.num=1, .props=&p};
	printf("AM FEND SetProp layer:%d\n", props.props[0].u.data);
	ret = AM_FEND_SetProp(FEND_DEV_NO, &props);
	return 0;
}

int main(int argc, char **argv)
{
	AM_DMX_OpenPara_t para;
	AM_FEND_OpenPara_t fpara;
	struct dvb_frontend_parameters p;
	fe_status_t status;
	int freq = 0;
	int layer = -1;
	
	memset(&fpara, 0, sizeof(fpara));
#if 1
	if(argc>1)
	{
		sscanf(argv[1], "%d", &freq);
	}
	if(argc>2)
	{
		sscanf(argv[2], "%d", &layer);
	}
	
	if(!freq)
	{
		freq = 618000000;
	}

	if(freq!=-1)
	{
		AM_TRY(AM_FEND_Open(FEND_DEV_NO, &fpara));

		p.frequency = freq;
#if 1
		p.inversion = INVERSION_AUTO;
		p.u.ofdm.bandwidth = BANDWIDTH_8_MHZ;
		p.u.ofdm.code_rate_HP = FEC_AUTO;
		p.u.ofdm.code_rate_LP = FEC_AUTO;
		p.u.ofdm.constellation = QAM_AUTO;
		p.u.ofdm.guard_interval = GUARD_INTERVAL_AUTO;
		p.u.ofdm.hierarchy_information = HIERARCHY_AUTO;
		p.u.ofdm.transmission_mode = TRANSMISSION_MODE_AUTO;
#else		
		p.u.qam.symbol_rate = 6875000;
		p.u.qam.fec_inner = FEC_AUTO;
		p.u.qam.modulation = QAM_64;
#endif		
	
		AM_TRY(AM_FEND_Lock(FEND_DEV_NO, &p, &status));
		
		if(status&FE_HAS_LOCK)
		{
			printf("locked\n");
		}
		else
		{
			printf("unlocked\n");
		}
	}
	
	if(layer!=-1)
		setlayer(layer);

#endif	
	memset(&para, 0, sizeof(para));
	AM_TRY(AM_DMX_Open(DMX_DEV_NO, &para));

{
	AM_DMX_Source_t s = AM_DMX_SRC_TS2;
	AM_TRY(AM_DMX_SetSource(DMX_DEV_NO, s));
	printf("TS SRC = %d\n", s);
}

	get_section();
	
	AM_DMX_Close(DMX_DEV_NO);
	if(freq!=-1)
		AM_FEND_Close(FEND_DEV_NO);
	
	return 0;
}
コード例 #28
0
ファイル: am_dmx_test.c プロジェクト: felipemogollon/dvb
static int get_section()
{
#ifdef PAT_TEST
	int fid;
#endif

#ifdef PMT_TEST
	int fid_pmt;
#endif

#ifdef EIT_TEST
	int fid_eit_pf, fid_eit_opf;
#endif

	struct dmx_sct_filter_params param;
	struct dmx_pes_filter_params pparam;
#ifdef PAT_TEST
	AM_TRY(AM_DMX_AllocateFilter(DMX_DEV_NO, &fid));
	AM_TRY(AM_DMX_SetCallback(DMX_DEV_NO, fid, dump_bytes, NULL));
#endif

#ifdef PMT_TEST
	AM_TRY(AM_DMX_AllocateFilter(DMX_DEV_NO, &fid_pmt));
	AM_TRY(AM_DMX_SetCallback(DMX_DEV_NO, fid_pmt, dump_bytes, NULL));
#endif

#ifdef EIT_TEST
	AM_TRY(AM_DMX_AllocateFilter(DMX_DEV_NO, &fid_eit_pf));
	AM_TRY(AM_DMX_SetCallback(DMX_DEV_NO, fid_eit_pf, dump_bytes, NULL));
	AM_TRY(AM_DMX_AllocateFilter(DMX_DEV_NO, &fid_eit_opf));
	AM_TRY(AM_DMX_SetCallback(DMX_DEV_NO, fid_eit_opf, dump_bytes, NULL));
#endif

#ifdef PAT_TEST
	memset(&param, 0, sizeof(param));
	param.pid = 0;
	param.filter.filter[0] = 0;
	param.filter.mask[0] = 0xff;
	//param.filter.filter[2] = 0x08;
	//param.filter.mask[2] = 0xff;

	param.flags = DMX_CHECK_CRC;
	
	AM_TRY(AM_DMX_SetSecFilter(DMX_DEV_NO, fid, &param));
#endif
	//pmt
#ifdef PMT_TEST
	memset(&param, 0, sizeof(param));
	param.pid = 0x3f2;
	param.filter.filter[0] = 0x2;
	param.filter.mask[0] = 0xff;
	param.filter.filter[1] = 0x0;
	param.filter.mask[1] = 0xff;
	param.filter.filter[2] = 0x65;
	param.filter.mask[2] = 0xff;
	param.flags = DMX_CHECK_CRC;
	
	AM_TRY(AM_DMX_SetSecFilter(DMX_DEV_NO, fid_pmt, &param));
#endif

#ifdef EIT_TEST
	memset(&param, 0, sizeof(param));
	param.pid = 0x12;
	param.filter.filter[0] = 0x4E;
	param.filter.mask[0] = 0xff;
	param.flags = DMX_CHECK_CRC;
	AM_TRY(AM_DMX_SetSecFilter(DMX_DEV_NO, fid_eit_pf, &param));
	
	memset(&param, 0, sizeof(param));
	param.pid = 0x12;
	param.filter.filter[0] = 0x4F;
	param.filter.mask[0] = 0xff;
	param.flags = DMX_CHECK_CRC;
	AM_TRY(AM_DMX_SetSecFilter(DMX_DEV_NO, fid_eit_opf, &param));
#endif

#ifdef PAT_TEST
	AM_TRY(AM_DMX_SetBufferSize(DMX_DEV_NO, fid, 32*1024));
	AM_TRY(AM_DMX_StartFilter(DMX_DEV_NO, fid));
#endif
#ifdef PMT_TEST
	AM_TRY(AM_DMX_SetBufferSize(DMX_DEV_NO, fid_pmt, 32*1024));
	AM_TRY(AM_DMX_StartFilter(DMX_DEV_NO, fid_pmt));
#endif
#ifdef EIT_TEST
	AM_TRY(AM_DMX_SetBufferSize(DMX_DEV_NO, fid_eit_pf, 32*1024));
	AM_TRY(AM_DMX_StartFilter(DMX_DEV_NO, fid_eit_pf));
	AM_TRY(AM_DMX_SetBufferSize(DMX_DEV_NO, fid_eit_opf, 32*1024));
	//AM_TRY(AM_DMX_StartFilter(DMX_DEV_NO, fid_eit_opf));
#endif
	
	sleep(100);
#ifdef PAT_TEST
	AM_TRY(AM_DMX_StopFilter(DMX_DEV_NO, fid));
	AM_TRY(AM_DMX_FreeFilter(DMX_DEV_NO, fid));
#endif	
#ifdef PMT_TEST
	AM_TRY(AM_DMX_StopFilter(DMX_DEV_NO, fid_pmt));
	AM_TRY(AM_DMX_FreeFilter(DMX_DEV_NO, fid_pmt));
#endif
#ifdef EIT_TEST
	AM_TRY(AM_DMX_StopFilter(DMX_DEV_NO, fid_eit_pf));
	AM_TRY(AM_DMX_FreeFilter(DMX_DEV_NO, fid_eit_pf));
	AM_TRY(AM_DMX_StopFilter(DMX_DEV_NO, fid_eit_opf));
	AM_TRY(AM_DMX_FreeFilter(DMX_DEV_NO, fid_eit_opf));
#endif
	//fclose(fp);
	
	return 0;
}
コード例 #29
0
ファイル: am_fendctrl_test.c プロジェクト: felipemogollon/dvb
int main(int argc, char **argv)
{
	AM_FEND_OpenPara_t para;
	AM_Bool_t loop=AM_TRUE;
	fe_status_t status;
	int fe_id=-1;	
	
	while(loop)
	{
		AM_FENDCTRL_DVBFrontendParameters_t fenctrl_para;
		int mode, current_mode;
		int freq, srate, qam;
		int bw;
		char buf[64], name[64];
		
		memset(&para, 0, sizeof(para));
		
		printf("Input fontend id, id=-1 quit\n");
		printf("id: ");
		scanf("%d", &fe_id);
		if(fe_id<0)
			return 0;
		
		para.mode = AM_FEND_DEMOD_DVBS;

		if(para.mode != AM_FEND_DEMOD_DVBS){
			printf("Input fontend mode: (0-DVBC, 1-DVBT)\n");
			printf("mode(0/1): ");
			scanf("%d", &mode);
			
			sprintf(name, "/sys/class/amlfe-%d/mode", fe_id);
			if(AM_FileRead(name, buf, sizeof(buf))==AM_SUCCESS) {
				if(sscanf(buf, ":%d", &current_mode)==1) {
					if(current_mode != mode) {
						int r;
						printf("Frontend(%d) dose not match the mode expected, change it?: (y/N) ", fe_id);
						getchar();/*CR*/
						r=getchar();
						if((r=='y') || (r=='Y'))
							para.mode = (mode==0)?AM_FEND_DEMOD_DVBC : 
										(mode==1)? AM_FEND_DEMOD_DVBT : 
										AM_FEND_DEMOD_AUTO;
					}
				}
			}
		}else{
			fenctrl_para.m_type = AM_FEND_DEMOD_DVBS;
			mode = 2;
		}

		AM_TRY(AM_FEND_Open(/*FEND_DEV_NO*/fe_id, &para));
		
		AM_TRY(AM_FEND_SetCallback(/*FEND_DEV_NO*/fe_id, fend_cb, NULL));
		
		printf("input frontend parameters, frequency=0 quit\n");
		if(para.mode != AM_FEND_DEMOD_DVBS){
			printf("frequency(Hz): ");
		}
		else{
			sec(fe_id);
			
			printf("frequency(KHz): ");
		}
		
		scanf("%d", &freq);
		if(freq!=0)
		{
			if(mode==0) {
				printf("symbol rate(kbps): ");
				scanf("%d", &srate);
				printf("QAM(16/32/64/128/256): ");
				scanf("%d", &qam);
				
				fenctrl_para.cable.para.frequency = freq;
				fenctrl_para.cable.para.u.qam.symbol_rate = srate*1000;
				fenctrl_para.cable.para.u.qam.fec_inner = FEC_AUTO;
				switch(qam)
				{
					case 16:
						fenctrl_para.cable.para.u.qam.modulation = QAM_16;
					break;
					case 32:
						fenctrl_para.cable.para.u.qam.modulation = QAM_32;
					break;
					case 64:
					default:
						fenctrl_para.cable.para.u.qam.modulation = QAM_64;
					break;
					case 128:
						fenctrl_para.cable.para.u.qam.modulation = QAM_128;
					break;
					case 256:
						fenctrl_para.cable.para.u.qam.modulation = QAM_256;
					break;
				}
			}else if(mode==1){
				printf("BW[8/7/6/5(AUTO) MHz]: ");
				scanf("%d", &bw);

				fenctrl_para.terrestrial.para.frequency = freq;
				switch(bw)
				{
					case 8:
					default:
						fenctrl_para.terrestrial.para.u.ofdm.bandwidth = BANDWIDTH_8_MHZ;
					break;
					case 7:
						fenctrl_para.terrestrial.para.u.ofdm.bandwidth = BANDWIDTH_7_MHZ;
					break;
					case 6:
						fenctrl_para.terrestrial.para.u.ofdm.bandwidth = BANDWIDTH_6_MHZ;
					break;
					case 5:
						fenctrl_para.terrestrial.para.u.ofdm.bandwidth = BANDWIDTH_AUTO;
					break;
				}

				fenctrl_para.terrestrial.para.u.ofdm.code_rate_HP = FEC_AUTO;
				fenctrl_para.terrestrial.para.u.ofdm.code_rate_LP = FEC_AUTO;
				fenctrl_para.terrestrial.para.u.ofdm.constellation = QAM_AUTO;
				fenctrl_para.terrestrial.para.u.ofdm.guard_interval = GUARD_INTERVAL_AUTO;
				fenctrl_para.terrestrial.para.u.ofdm.hierarchy_information = HIERARCHY_AUTO;
				fenctrl_para.terrestrial.para.u.ofdm.transmission_mode = TRANSMISSION_MODE_AUTO;
			}else{
				printf("dvb sx test\n");

				int polar;
				printf("polar: ");
				scanf("%d", &(polar));
				fenctrl_para.sat.polarisation = polar;

				fenctrl_para.sat.para.frequency = freq;

				printf("symbol rate: ");
				scanf("%d", &(fenctrl_para.sat.para.u.qpsk.symbol_rate));
			}

			int sync = 0;
			printf("async-0, sync-1: ");			
			scanf("%d", &(sync));

			if(sync == 0)
			{
				AM_TRY(AM_FENDCTRL_SetPara(/*FEND_DEV_NO*/fe_id, &fenctrl_para));
			}
			else
			{
				AM_TRY(AM_FENDCTRL_Lock(/*FEND_DEV_NO*/fe_id, &fenctrl_para, &status));
				printf("lock status: 0x%x\n", status);
			}

		}
		else
		{
			loop = AM_FALSE;
		}

		printf("fend close: ");
		scanf("%d", &(fe_id));
		
		AM_TRY(AM_FEND_Close(/*FEND_DEV_NO*/fe_id));
	}
	
	
	return 0;
}