Пример #1
0
/**
 * \brief init feeder
 * \param audec pointer to audec
 * \return 0 on success otherwise -1 if an error occurred
 */
int feeder_init(aml_audio_dec_t *audec)
{
    int ret;
    dsp_operations_t *dsp_ops;

    dsp_ops = &audec->adsp_ops;

    audec->format = get_audio_format();
    if (audec->format == ADEC_AUDIO_FORMAT_UNKNOWN) {
        adec_print("Unknown audio format!");
        return -1;
    }

    ret = audiodsp_init(dsp_ops);
    if (ret) {
        adec_print("audio dsp init failed!");
        return -1;
    }
		
    ret = audiodsp_start(audec);
    if (ret == 0) {
        dsp_ops->dsp_on = 1;
        dsp_ops->dsp_read = audiodsp_stream_read;
        dsp_ops->get_cur_pts = audiodsp_get_pts;
        dsp_ops->get_cur_pcrscr = audiodsp_get_pcrscr;
	      dsp_ops->set_cur_apts    = audiodsp_set_apts;	
    } else {
        audiodsp_release(dsp_ops);
        dsp_ops->dsp_on = 0;
        dsp_ops->dsp_read = NULL;
        dsp_ops->get_cur_pts = NULL;
        dsp_ops->get_cur_pcrscr = NULL;

        /* TODO: amport init */
    }

    return ret;
}
Пример #2
0
static int audiodsp_ioctl(struct inode *node, struct file *file, unsigned int cmd,
		      unsigned long args)
{
	struct audiodsp_priv *priv=audiodsp_privdata();
	struct audiodsp_cmd *a_cmd;
	char name[64];
	int len;
	unsigned long pts;
	int ret=0;
	unsigned long *val=(unsigned long *)args;
#ifdef ENABLE_WAIT_FORMAT
	static int wait_format_times=0;
#endif	
	switch(cmd)
		{
		case AUDIODSP_SET_FMT:
			priv->stream_fmt=args;
            if(args == MCODEC_FMT_DTS)
              	IEC958_mode_codec = 1;
            else if(args == MCODEC_FMT_AC3)
            	IEC958_mode_codec = 2; 	
            else
            	IEC958_mode_codec = 0;
			break;
		case AUDIODSP_START:
			if(IEC958_mode_raw_last != IEC958_mode_raw || IEC958_mode_codec_last !=  IEC958_mode_codec)
			{
				IEC958_mode_raw_last = IEC958_mode_raw;
				IEC958_mode_codec_last = IEC958_mode_codec;
				aml_alsa_hw_reprepare();
			}	
			priv->decoded_nb_frames = 0;
			priv->format_wait_count = 0;
			if(priv->stream_fmt<=0)
				{
				DSP_PRNT("Audio dsp steam format have not set!\n");
				}
			else
				{
				ret=audiodsp_start();
				}
			break;
		case AUDIODSP_STOP:
			//DSP_PRNT("audiodsp command stop\n");
			stop_audiodsp_monitor(priv);
			dsp_stop(priv);
			priv->decoded_nb_frames = 0;
			priv->format_wait_count = 0;
			break;
#ifdef ENABLE_WAIT_FORMAT
		case AUDIODSP_DECODE_START:			
			if(priv->dsp_is_started)
				{
				dsp_codec_start(priv);
				wait_format_times=0;
				}
			else
				{
				DSP_PRNT("Audio dsp have not started\n");
				}			
			break;
		case AUDIODSP_WAIT_FORMAT:
			if(priv->dsp_is_started)
				{
				struct audio_info *audio_format;
				int ch = 0;
				audio_format = get_audio_info();
				
				wait_format_times++;
				
				if(wait_format_times>100){
					int audio_info = DSP_RD(DSP_AUDIO_FORMAT_INFO);
					if(audio_info){
						priv->frame_format.channel_num = audio_info&0xf;
						if(priv->frame_format.channel_num)
							priv->frame_format.valid |= CHANNEL_VALID;
						priv->frame_format.data_width= (audio_info>>4)&0x3f;
						if(priv->frame_format.data_width)
							priv->frame_format.valid |= DATA_WIDTH_VALID;
						priv->frame_format.sample_rate = (audio_info>>10);
						if(priv->frame_format.sample_rate)
							priv->frame_format.valid |= SAMPLE_RATE_VALID;
						DSP_PRNT("warning::got info from mailbox failed,read from regiser\n");
						ret = 0;
					}else{
						DSP_PRNT("dsp have not set the codec stream's format details,valid=%x\n",
						priv->frame_format.valid);		
						priv->format_wait_count++;
						if(priv->format_wait_count > 5){						
							if(audio_format->channels&&audio_format->sample_rate){
								priv->frame_format.channel_num = audio_format->channels>2?2:audio_format->channels;
								priv->frame_format.sample_rate = audio_format->sample_rate;
								priv->frame_format.data_width = 16;
								priv->frame_format.valid = CHANNEL_VALID|DATA_WIDTH_VALID|SAMPLE_RATE_VALID;
								DSP_PRNT("we have not got format details from dsp,so use the info got from the header parsed instead\n");
								ret = 0;
							}else{
								ret = -1;
							}
						}else{
							ret=-1;
						}
					}
				}else if(priv->frame_format.valid == (CHANNEL_VALID|DATA_WIDTH_VALID|SAMPLE_RATE_VALID)){