int ipanel_porting_video_location(int x, int y, int w, int h) { int ret = -1; struct Rect SrcRect; struct Rect DstRect; ipanel_porting_dprintf("[ipanel_porting_video_location],rect (x=%d,y=%d,w=%d,h=%d).\n",x,y,w,h); if ( (x>=0 && x<=IPANEL_SCREENW) && (y>=0 && y<=IPANEL_SCREENH) && (w>=0 && w<=IPANEL_SCREENW) && (h>=0 && h<=IPANEL_SCREENH) ) { if (x==0 && y==0 && w==0 && h==0) { w = PICTURE_WIDTH; h = PICTURE_HEIGHT; } else { x+=DISPLAY_POS_X; y= (y+DISPLAY_POS_Y)*5; h *= 5; } /*Set physical TV screen area here*/ SrcRect.uStartX = 0; SrcRect.uWidth = PICTURE_WIDTH; SrcRect.uStartY = 0; SrcRect.uHeight = PICTURE_HEIGHT; DstRect.uStartX = x; DstRect.uStartY = y; DstRect.uWidth = w; DstRect.uHeight = h; // vpo_win_onoff(g_vpo_dev,FALSE); if(RET_SUCCESS == vpo_zoom(g_vpo_dev ,&SrcRect , &DstRect)) ret = 0; else ipanel_porting_dprintf("[ipanel_porting_video_location] failed.\n"); // vpo_win_onoff(g_vpo_dev,TRUE); } return ret; }
INT32_T ipanel_adec_init(VOID) { INT32_T ret = IPANEL_ERR; CNXT_AUDIO_STATUS audstat ; bool status ; /* enable AC3 pass through */ cnxt_ac3_passthru (TRUE); status = gen_audio_init(FALSE, FALSE); if (FALSE == status) { ipanel_porting_dprintf("[iPanelAudioInit] gen_audio_init failed\n"); goto AUDIO_INIT_FAILED; } audstat = cnxt_audio_open(&m_ipanel_haudio); if( audstat != CNXT_AUDIO_OK) { ipanel_porting_dprintf("[ipanel_porting_adec_open] open audio handle failed! \n"); goto AUDIO_INIT_FAILED; } return IPANEL_OK; AUDIO_INIT_FAILED: return ret; }
/****************************************************************************** ** Description : pause playing audio; ** Input : None; ** Output : None; ** Return : None; ******************************************************************************/ static INT32_T ipanel_adec_pause(VOID) { INT32_T ret = IPANEL_ERR; DMX_STATUS dmxstat; /* mute the audio */ hw_set_aud_mute(TRUE); /* stop the audio */ gen_audio_stop(); dmxstat=cnxt_dmx_channel_control(gDemuxInstance, g_ipanel_audio_channel, (gencontrol_channel_t) GEN_DEMUX_DISABLE); if( DMX_STATUS_OK != dmxstat ) { ipanel_porting_dprintf("[ipanel_audio_pause] pause audio failed! \n"); return ret ; } hw_set_aud_mute(FALSE); ret = IPANEL_OK ; ipanel_porting_dprintf("[ipanel_audio_pause] pause audio success! \n"); g_audio_play_status = IPANEL_AUDIO_STATUS_STOP ; return ret; }
/****************************************************************************** ** Description : resume playing audio; ** Input : None; ** Output : None; ** Return : None; ******************************************************************************/ static INT32_T ipanel_adec_resume(VOID) { INT32_T ret= IPANEL_ERR; DMX_STATUS dmxstat; ipanel_porting_dprintf("[ipanel_audio_resume] is called \n"); /* play the audio */ gen_audio_play( FALSE ); /*play audio*/ dmxstat=cnxt_dmx_channel_control(gDemuxInstance, g_ipanel_audio_channel, (gencontrol_channel_t) GEN_DEMUX_ENABLE); if( DMX_STATUS_OK != dmxstat ) { ipanel_porting_dprintf("[ipanel_audio_resume] resume audio failed! \n"); return ret ; } ret = IPANEL_OK; ipanel_porting_dprintf("[ipanel_audio_resume] resume video success! \n"); g_audio_play_status = IPANEL_AUDIO_STATUS_PLAY ; return ret; }
int ipanel_porting_video_stop(void) { ipanel_porting_dprintf("[ipanel_porting_video_stop] called..\n"); ipanel_porting_av_stop(); /*stop the physical opened media*/ return 0; }
/*************************************************************************************************** 功能:对声音输出设置进行一个操作,或者用于设置和获取声音输出设备的参数和属性 原型:INT32_T ipanel_porting_audio_output_ioctl(UINT32_T handle, IPANEL_AOUT_IOCTL_e op, VOID *arg) 参数说明: 输入参数: audio: 输出设备句柄 op - 操作命令 typedef enum { IPANEL_AOUT_SET_OUTPUT =1, IPANEL_AOUT_SET_VOLUME, IPANEL_AOUT_SET_BALANCE } IPANEL_AOUT_IOCTL_e; arg - 操作命令所带的参数,当传递枚举型或32位整数值时,arg可强制转换成对应数据类型。 op, arg取值见下表: +---------------------+-------------------------+-----------------------------+ | op | arg | 说明 | +---------------------+-------------------------+-----------------------------+ | IPANEL_AOUT_ |typedef enum { |指定声音输出设备 | | SET_OUTPUT | IPANEL_AOUT_DEVICE_ANALOG_STERO=0x01,//立体声输出 | | | IPANEL_AOUT_DEVICE_ANALOG_MUTI=0x02, //多声道输出 | | | IPANEL_AOUT_DEVICE_SPDIF=0x04, //S/PDIF输出 | | | IPANEL_AOUT_DEVICE_HDMI=0x08, //HDMI输出 | | | IPANEL_AOUT_DEVICE_I2S=0x10, //I2S输出 | | | IPANEL_AOUT_DEVICE_ALL = 0xff, //所有端口 | | |}IPANEL_AOUT_DEVICE_e; | | +---------------------+-------------------------+-----------------------------+ | IPANEL_AOUT_ |0~100整数值 |设置音频输出音量 | | SET_VOLUME | | | +---------------------+-------------------------+-----------------------------+ | IPANEL_AOUT_ |0~100整数值 |设置音频输出左右声道均衡参数,| | SET_BALANCE | |默认值为0. | +---------------------+-------------------------+-----------------------------+ 输出参数:无 返 回: IPANEL_OK:成功; IPANEL_ERR:失败。 ****************************************************************************************************/ INT32_T ipanel_porting_audio_output_ioctl(UINT32_T handle, IPANEL_AOUT_IOCTL_e op, VOID *arg) { INT32_T ret = IPANEL_OK; UINT32_T oparg = (UINT32_T)arg; ipanel_porting_dprintf("[ipanel_porting_audio_output_ioctl] handle=0x%x, op=%d, \ arg=%p\n", handle, op, arg); switch (op) { case IPANEL_AOUT_SET_OUTPUT : break; case IPANEL_AOUT_SET_VOLUME : ret = ipanel_audio_set_output_volume(oparg); break; case IPANEL_AOUT_SET_BALANCE : break; case IPANEL_AOUT_GET_VOLUME: break; default : ipanel_porting_dprintf("[ipanel_porting_audio_output_ioctl] ERROR parameter!\n"); ret = IPANEL_ERR; } return ret; }
/*************************************************************************************************** 功能:关闭指定的解码单元。 原型:INT32_T ipanel_porting_adec_close(UINT32_T decoder) 参数说明: 输入参数:decoder: 要关闭的解码单元句柄。 输出参数:无 返 回: IPANEL_OK:成功; IPANEL_ERR:失败。 ****************************************************************************************************/ INT32_T ipanel_porting_adec_close(UINT32_T decoder) { INT32_T ret = IPANEL_OK; ipanel_porting_dprintf("[ipanel_porting_adec_close] decoder=0x%x\n", decoder); return ret; }
/*************************************************************************************************** 功能:打开一个解码单元。 原型:UINT32_T ipanel_porting_adec_open(VOID) 参数说明: 输入参数:无 输出参数:无 返 回: !=IPANEL_NULL:成功,解码器句柄; ==IPANEL_NULL:失败 ****************************************************************************************************/ UINT32_T ipanel_porting_adec_open(VOID) { UINT32_T decoder = 0xA0D0; ipanel_porting_dprintf("[ipanel_porting_adec_open] is called!\n"); return decoder; }
/*************************************************************************************************** 功能:打开音频输出管理单元 原型:UINT32_T ipanel_porting_audio_output_open(VOID) 参数说明: 输入参数:无 输出参数:无 返 回: != IPANEL_NULL:成功,音频输出管理单元句柄; == IPANEL_NULL:失败 ****************************************************************************************************/ UINT32_T ipanel_porting_audio_output_open(VOID) { UINT32_T handle = 0xA0E0; ipanel_porting_dprintf("[ipanel_porting_audio_output_open] is called!\n"); return handle; }
/*************************************************************************************************** 功能:关闭指定的音频输出单元 原型:INT32_T ipanel_porting_audio_output_close(UINT32_T handle) 参数说明: 输入参数:handle: 要关闭的输出管理单元句柄 输出参数:无 返 回: IPANEL_OK:成功; IPANEL_ERR:失败。 ****************************************************************************************************/ INT32_T ipanel_porting_audio_output_close(UINT32_T handle) { INT32_T ret = IPANEL_OK; ipanel_porting_dprintf("[ipanel_porting_audio_output_close] handle=0x%x\n", handle); return ret; }
static INT32_T ipanel_audio_set_output_volume(UINT32_T volume) { INT32_T ret = IPANEL_ERR; PCM_STATUS pcmstat ; u_int8 left_volume , right_volume ; ipanel_porting_dprintf("[ipanel_audio_set_output_volume] vol=%d\n",volume); if( IPANEL_ENABLE == g_mute_mode) { hw_set_aud_mute(FALSE); } if (volume <= 100) { volume += 60; // 增加一个调整值,不然声音没有线性增长 left_volume = right_volume = (volume*31)/100; if(left_volume > 31) { left_volume = right_volume = 31; } else if(volume <= 60) { left_volume = right_volume = 0; } pcmstat = cnxt_pcm_set_volume_mpeg(left_volume, right_volume); if( pcmstat != PCM_ERROR_OK ) { ipanel_porting_dprintf("[ipanel_audio_set_output_volume] set volume failed! \n"); } else { ret = IPANEL_OK; } } return ret; }
/****************************************************************************** ** Description : set audio decode format ** Input : None; ** Output : None; ** Return : None; ******************************************************************************/ static INT32_T ipanel_adec_set_channel_mode(UINT32_T decoder, UINT32_T mode) { INT32_T ret = IPANEL_ERR ; PCM_STATUS status; cnxt_pcm_channel_mode_t pcm_mode; hw_set_aud_mute(TRUE); switch(mode) { case IPANEL_AUDIO_MODE_STEREO: pcm_mode = PCM_CM_STEREO ; break; case IPANEL_AUDIO_MODE_LEFT_MONO: pcm_mode = PCM_CM_MONO_LEFT ; break; case IPANEL_AUDIO_MODE_RIGHT_MONO: pcm_mode = PCM_CM_MONO_RIGHT ; break; case IPANEL_AUDIO_MODE_MIX_MONO: pcm_mode = PCM_CM_MONO_MIX ; break; case IPANEL_AUDIO_MODE_STEREO_REVERSE: pcm_mode = PCM_CM_STEREO_SWAP ; break; default: pcm_mode = PCM_CM_STEREO ; break; } status=cnxt_pcm_set_channel_mode_mpeg(pcm_mode); if( PCM_ERROR_OK != status ) { ipanel_porting_dprintf("[ipanel_set_audio_channel_mode] set audio channel mode failed!\n"); return ret ; } ipanel_WaitForAudioValid(VALID_AUDIO_TIMEOUT, CLEAN_AUDIO_WAIT_TIME); hw_set_aud_mute(FALSE); return (ret = IPANEL_OK); }
INT32_T ipanel_porting_adec_ioctl(UINT32_T decoder, IPANEL_ADEC_IOCTL_e op, VOID *arg) { INT32_T ret = IPANEL_OK; u_int32 value; UINT32_T oparg = (UINT32_T)arg; ipanel_porting_dprintf("[ipanel_porting_adec_ioctl] decoder=0x%x, \ op=%d, arg=%p\n", decoder, op, arg); switch (op) { case IPANEL_ADEC_SET_SOURCE : /* 指定Audio decoder输入数据来源 */ break; case IPANEL_ADEC_START : /* 启动指定的decoder,并指出输入的数据格式*/ ipanel_adec_start(); break; case IPANEL_ADEC_STOP : /* 停止指定的decoder*/ ipanel_adec_stop(); break; case IPANEL_ADEC_PAUSE : /* 暂定已启动的decoder解码单元的解码。*/ ret = ipanel_adec_pause(); break; case IPANEL_ADEC_RESUME : /* 恢复已暂定的decoder解码单元的解码。*/ ret = ipanel_adec_resume(); break; case IPANEL_ADEC_CLEAR : /* 清空Decoder解码单元内部缓冲区的内容*/ break; case IPANEL_ADEC_SYNCHRONIZE : /* 禁止和允许视音频同步功能*/ break; case IPANEL_ADEC_SET_CHANNEL_MODE : /* 设置双声道输出模式。*/ ret = ipanel_adec_set_channel_mode(decoder, oparg); break; case IPANEL_ADEC_SET_MUTE : /* 禁止和允许静音功能。*/ ipanel_adec_set_mute(oparg); break; case IPANEL_ADEC_SET_PASS_THROUGH : /* 设置解码器是否对输入流解码, 不用解码的流解码器工作在旁路模式*/ break; case IPANEL_ADEC_SET_VOLUME : /* 设置输出音量大小 */ ipanel_adec_set_volume(oparg); break; case IPANEL_ADEC_GET_BUFFER_RATE : /* 返回音频解码器前级buffer占用情况,以百分表示 */ break; case IPANEL_ADEC_SET_SYNC_OFFSET : /* 90KHz时钟的计数值,设置音频播放单元与系统时间的差值 */ break; case IPANEL_ADEC_GET_BUFFER : /* 向音频解码设备获取数据缓冲区 */ break; case IPANEL_ADEC_PUSH_STREAM : /* 向音频解码器输入压缩音频数据。 */ break; case IPANEL_ADEC_GET_BUFFER_CAP : /* 获得解码器缓冲buffer的大小(缓冲能力) */ break; case IPANEL_ADEC_SET_CONFIG_PARAMS : /* 获取解码器工作参数,参数串符合SDP描叙格式 */ break; case IPANEL_ADEC_GET_CURRENT_PTS : /* 获取当前解码数据单元的时间戳 */ ipanel_get_apts(&value); *((UINT32_T*)arg) = value ; break; default : ipanel_porting_dprintf("[ipanel_porting_adec_ioctl] ERROR parameter!\n"); ret = IPANEL_ERR; } return ret; }
int ipanel_get_service_ByPID(Service_Info *service) { int i=0; short prog_cnt = 0; P_NODE prog; T_NODE tp; prog_cnt = get_prog_num(VIEW_ALL|PROG_ALL_MODE, 0); for(i = 0; i < prog_cnt; i++) { if(SUCCESS!=get_prog_at(i, &prog)) return -1; ipanel_porting_dprintf("-->[ipanel_get_service_ByPID] service_id=%d,service_type=%d,.\n", prog.prog_number,prog.service_type); if(service->service_type!=prog.service_type) continue; if(service->video_pid != 0x0) { //use video_pid cross frq and do something if((service->video_pid == prog.video_pid)&&(service->audio_pid== (UINT32)prog.audio_pid[0])&&(service->pcr_pid==prog.pcr_pid)) { progpos=get_prog_pos(prog.prog_id); if(SUCCESS != get_tp_by_id(prog.tp_id, &tp)) { ipanel_porting_dprintf("[ipanel_get_service_ByPID] get_tp_by_id failed \n"); return -1; } service->ts_id = tp.t_s_id; service->net_id = tp.network_id; service->frequency = tp.frq; service->symbol_rate = tp.sym; service->modulation = tp.FEC_inner; service->service_type = prog.service_type; service->pcr_pid = prog.pcr_pid; service->video_pid = prog.video_pid; service->audio_pid = (UINT32)prog.audio_pid[0]; service->service_id=prog.prog_number; return 0; } } else if(service->audio_pid != 0x0) { //use audio_pid cross frq and do something // if(service->audio_pid == (UINT32)prog.audio_pid[0]) if((service->video_pid == prog.video_pid)&&(service->audio_pid== (UINT32)prog.audio_pid[0])&&(service->pcr_pid==prog.pcr_pid)) { progpos=get_prog_pos(prog.prog_id); if(SUCCESS != get_tp_by_id(prog.tp_id, &tp)) { ipanel_porting_dprintf("[ipanel_get_service_ByPID] get_tp_by_id failed \n"); return -1; } service->ts_id = tp.t_s_id; service->net_id = tp.network_id; service->frequency = tp.frq; service->symbol_rate = tp.sym; service->modulation = tp.FEC_inner; service->service_type = prog.service_type; service->pcr_pid = prog.pcr_pid; service->video_pid = prog.video_pid; service->audio_pid = (UINT32)prog.audio_pid[0]; service->service_id=prog.prog_number; return 0; } } } ipanel_porting_dprintf("[ipanel_get_service_ByPID] no found failed \n"); return -1; }
int ipanel_porting_dvb_select_av(int pcr_pid, int emm_pid, int vpid, int apid, int audio_ecm_pid, int video_ecm_pid,int servicetype) { RET_CODE ret_code = 0; Service_Info tmp_service; dprintf("[ipanel_porting_dvb_select_av] V/A/Pcr = %d/%d/%d video_status = %d \n",vpid,apid,pcr_pid, video_status); //return 0; if((apid==0)&&(vpid==0)&&(pcr_pid==0)) { return -1; } if((audioPid==apid) && (videoPid==vpid) && (pcrPid==pcr_pid)) { return 0; } else if((audioPid||videoPid||pcrPid)&&(video_status==1)) { ipanel_porting_av_stop(); } /*here the program PID, audio PID video PID were fixed , so this demo code was banded with a specified ts. just modify these related marco when you use this demo code. */ io_parameter.io_buff_in = (UINT8 *)PID_list; PID_list[0] = vpid;//pCmd->pids.video_id; PID_list[1] = apid;//pCmd->pids.audio_id; PID_list[2] = pcr_pid;//pCmd->pids.pcr_id; pcrPid = pcr_pid; //if(ipanel_get_run_mode()==1) //if mode is flash mode,search by vid or aid { int ret=0; tmp_service.video_pid = vpid; tmp_service.audio_pid = apid; tmp_service.pcr_pid=pcr_pid; tmp_service.service_type=servicetype; if(ipanel_get_run_mode()!=1) { *((volatile UINT8 *)0xb800002C) &= ~0x10; //set pin-mux to S-Flash osal_task_sleep(2000); } ret = ipanel_get_service_ByPID(&tmp_service); if(ipanel_get_run_mode()!=1) { *((volatile UINT8 *)0xb800002C) |= 0x10; //set pin-mux to Ethernet osal_task_sleep(2000); //for not crash quickly } if(ret == SUCCESS) { PID_list[2] = pcrPid = tmp_service.pcr_pid; if(tmp_service.frequency != cur_freq ) { my_ts_id = tmp_service.ts_id; ipanel_porting_delivery_tune(tmp_service.frequency*100,tmp_service.symbol_rate*10,(tmp_service.modulation-3)); osal_task_sleep(300); ipanel_porting_dprintf("[ipanel_porting_dvb_select_av] ts_id : 0x%x ,tune %d.\n",tmp_service.ts_id,tmp_service.frequency); } } else { ipanel_porting_dprintf("[ipanel_porting_dvb_select_av] can't get the service.but still play av by pid\n"); //return -1; } } UINT32 create_stream = 0; UINT32 enable_stream = 0; if(vpid && apid) { create_stream = IO_CREATE_AV_STREAM; enable_stream = IO_STREAM_ENABLE; } else if((vpid==0) && apid) { create_stream = IO_CREATE_AUDIO_STREAM; enable_stream = AUDIO_STREAM_ENABLE; } else if((apid==0) && vpid) { create_stream = IO_CREATE_VIDEO_STREAM; enable_stream = VIDEO_STREAM_ENABLE; } if(create_stream!=0) ret_code = dmx_io_control(g_dmx_dev,create_stream,(UINT32)&io_parameter); if(ret_code != RET_SUCCESS) { dprintf("[ipanel_porting_av_start] dmx create stream fail\n"); return -1; } if(vpid) { ret_code = vdec_start(g_decv_dev); if(ret_code != RET_SUCCESS) { dprintf("[ipanel_porting_av_start] cc2: VDec_Decode() fail\n"); return -1; } else { dprintf("[ipanel_porting_av_start] cc2: vdec_start() OK\n"); } videoPid = vpid; } if(apid) { deca_io_control(g_deca_dev, DECA_SET_STR_TYPE, AUDIO_MPEG2); ret_code = deca_start(g_deca_dev,0); /* open the audio device */ if(ret_code != RET_SUCCESS) { dprintf("[ipanel_porting_av_start] cc2: deca_start() fail \n"); return -1; } else { dprintf("[ipanel_porting_av_start] cc2: deca_start() OK \n"); } audioPid = apid; } if(enable_stream!=0) ret_code = dmx_io_control(g_dmx_dev,enable_stream,(UINT32)&io_parameter); if(ret_code != RET_SUCCESS) { dprintf("[ipanel_porting_av_start] cc2: dmx enable stream fail\n"); return -1; } else { dprintf("[ipanel_porting_av_start] cc2: dmx enable stream OK\n"); } video_status = 1; if(progpos!=0xffff){ api_mcas_start_service(0); api_mcas_start_transponder(); si_monitor_on(progpos); } dprintf("[ipanel_porting_av_start] cc2: V/A/Pcr = %d/%d/%d\n",PID_list[0],PID_list[1],PID_list[2]); return 0; }