int audiodsp_start(void) { struct audiodsp_priv *priv=audiodsp_privdata(); struct audiodsp_microcode *pmcode; struct audio_info *audio_info; int ret,i; priv->frame_format.valid=0; priv->decode_error_count=0; priv->last_valid_pts=0; priv->out_len_after_last_valid_pts = 0; priv->decode_fatal_err = 0; priv->first_lookup_over = 0; pmcode=audiodsp_find_supoort_mcode(priv,priv->stream_fmt); if(pmcode==NULL) { DSP_PRNT("have not find a valid mcode for fmt(0x%x)\n",priv->stream_fmt); return -1; } stop_audiodsp_monitor(priv); dsp_stop(priv); ret=dsp_start(priv,pmcode); if(ret==0){ start_audiodsp_monitor(priv); #ifdef CONFIG_AM_VDEC_REAL if((pmcode->fmt == MCODEC_FMT_COOK) || (pmcode->fmt == MCODEC_FMT_RAAC) || (pmcode->fmt == MCODEC_FMT_AMR) || (pmcode->fmt == MCODEC_FMT_WMA) || (pmcode->fmt == MCODEC_FMT_ADPCM)|| (pmcode->fmt == MCODEC_FMT_PCM) || (pmcode->fmt == MCODEC_FMT_WMAPRO)|| (pmcode->fmt == MCODEC_FMT_ALAC)|| (pmcode->fmt & MCODEC_FMT_AC3) || (pmcode->fmt & MCODEC_FMT_EAC3) || (pmcode->fmt == MCODEC_FMT_APE) || (pmcode->fmt == MCODEC_FMT_FLAC)) { DSP_PRNT("dsp send audio info\n"); for(i = 0; i< 2000;i++){ if(DSP_RD(DSP_AUDIOINFO_STATUS) == DSP_AUDIOINFO_READY)//maybe at audiodsp side,INT not enabled yet,so wait a while break; msleep(1); } if(i == 2000) DSP_PRNT("audiodsp not ready for info \n"); DSP_WD(DSP_AUDIOINFO_STATUS,0); audio_info = get_audio_info(); DSP_PRNT("kernel sent info first 4 byte[0x%x],[0x%x],[0x%x],[0x%x]\n\t",audio_info->extradata[0],\ audio_info->extradata[1],audio_info->extradata[2],audio_info->extradata[3]); DSP_WD(DSP_GET_EXTRA_INFO_FINISH, 0); while(1){ dsp_mailbox_send(priv, 1, M2B_IRQ4_AUDIO_INFO, 0, (const char*)audio_info, sizeof(struct audio_info)); msleep(100); if(DSP_RD(DSP_GET_EXTRA_INFO_FINISH) == 0x12345678) break; } } #endif } return ret; }
static void audiodsp_allow_sleep(void) { struct audiodsp_priv *priv=audiodsp_privdata(); printk("audiodsp allow sleep\n"); //wake_unlock(&priv->wakelock); }
static void audiodsp_prevent_sleep(void) { struct audiodsp_priv* priv = audiodsp_privdata(); printk("audiodsp prevent sleep\n"); //wake_lock(&priv->wakelock); }
static void audiodsp_allow_sleep(void) { /*struct audiodsp_priv *priv= */ audiodsp_privdata(); pr_info("audiodsp allow sleep\n"); /* wake_unlock(&priv->wakelock); */ }
static void audiodsp_prevent_sleep(void) { /*struct audiodsp_priv* priv = */ audiodsp_privdata(); pr_info("audiodsp prevent sleep\n"); /* wake_lock(&priv->wakelock); */ }
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)){