/* must be called with audio->lock held */ static int audio_in_enable(struct audio_in *audio) { struct audmgr_config cfg; int rc; if (audio->enabled) return 0; cfg.tx_rate = audio->samp_rate; cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE; cfg.def_method = RPC_AUD_DEF_METHOD_RECORD; if (audio->type == AUDREC_CMD_TYPE_0_INDEX_WAV) cfg.codec = RPC_AUD_DEF_CODEC_PCM; else cfg.codec = RPC_AUD_DEF_CODEC_AAC; cfg.snd_method = RPC_SND_METHOD_MIDI; rc = audmgr_enable(&audio->audmgr, &cfg); if (rc < 0) return rc; if (msm_adsp_enable(audio->audpre)) { MM_ERR("msm_adsp_enable(audpre) failed\n"); return -ENODEV; } if (msm_adsp_enable(audio->audrec)) { MM_ERR("msm_adsp_enable(audrec) failed\n"); return -ENODEV; } audio->enabled = 1; audio_in_dsp_enable(audio, 1); return 0; }
/* must be called with audio->lock held */ static int audio_amrnb_in_enable(struct audio_amrnb_in *audio) { struct audmgr_config cfg; int rc; if (audio->enabled) return 0; cfg.tx_rate = RPC_AUD_DEF_SAMPLE_RATE_8000; cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE; cfg.def_method = RPC_AUD_DEF_METHOD_RECORD; cfg.codec = RPC_AUD_DEF_CODEC_AMR_NB; cfg.snd_method = RPC_SND_METHOD_MIDI; rc = audmgr_enable(&audio->audmgr, &cfg); if (rc < 0) return rc; if (audrectask_enable(audio->enc_type, audio_amrnb_in_dsp_event, audio)) { audmgr_disable(&audio->audmgr); MM_ERR("audrec_enable failed\n"); return -ENODEV; } audio->enabled = 1; audio_amrnb_in_dsp_enable(audio, 1); return 0; }
int audio_configure(struct msm_audio *prtd) { struct audmgr_config cfg; int rc; if (prtd->enabled) return 0; /* refuse to start if we're not ready with first buffer */ if (!prtd->out[0].used) return -EIO; cfg.tx_rate = 0; cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_48000; cfg.def_method = RPC_AUD_DEF_METHOD_HOST_PCM; cfg.codec = RPC_AUD_DEF_CODEC_PCM; cfg.snd_method = RPC_SND_METHOD_MIDI; rc = audmgr_enable(&prtd->audmgr, &cfg); if (rc < 0) return rc; if (audpp_enable(AUDPP_ALSA_DECODER, audio_dsp_event, prtd)) { printk(KERN_ERR "audio: audpp_enable() failed\n"); audmgr_disable(&prtd->audmgr); return -ENODEV; } prtd->enabled = 1; return 0; }
/* must be called with audio->lock held */ static int audio_enable(struct audio *audio) { struct audmgr_config cfg; int rc; pr_info("audio_mp3_enable()\n"); if (audio->enabled) return 0; audio->out_tail = 0; audio->out_needed = 0; cfg.tx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE; cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_48000; cfg.def_method = RPC_AUD_DEF_METHOD_PLAYBACK; cfg.codec = RPC_AUD_DEF_CODEC_MP3; cfg.snd_method = RPC_SND_METHOD_MIDI; audio_prevent_sleep(audio); audio->audmgr.cb = audio_mp3_audmgr_cb; rc = audmgr_enable(&audio->audmgr, &cfg); if (rc < 0) { pr_err("audio_mp3: audmgr_enable() failed\n"); audio_allow_sleep(audio); return rc; } if (msm_adsp_get("AUDPLAY0TASK", &audio->audplay, &audplay_adsp_ops, audio)) { pr_err("audio_mp3: failed to get audplay0 dsp module\n"); goto err_get_adsp; } if (msm_adsp_enable(audio->audplay)) { pr_err("audio_mp3: msm_adsp_enable(audplay) failed\n"); goto err_enable_adsp; } if (audpp_enable(audio->dec_id, audio_dsp_event, audio_modem_event, audio)) { pr_err("audio_mp3: audpp_enable() failed\n"); goto err_enable_audpp; } atomic_set(&audio->image_swap, 0); audio->enabled = 1; htc_pwrsink_audio_set(PWRSINK_AUDIO_MP3, 100); return 0; err_enable_audpp: msm_adsp_disable(audio->audplay); err_enable_adsp: msm_adsp_put(audio->audplay); err_get_adsp: audmgr_disable(&audio->audmgr); audio_allow_sleep(audio); return -ENODEV; }
/* must be called with audio->lock held */ static int audio_enable(struct audio *audio) { struct audmgr_config cfg; int rc; MM_INFO("[CLK]\n"); /* Macro prints the file name and function */ if (audio->enabled) return 0; /* refuse to start if we're not ready */ if (!audio->out[0].used || !audio->out[1].used) return -EIO; /* we start buffers 0 and 1, so buffer 0 will be the * next one the dsp will want */ audio->out_tail = 0; audio->out_needed = 0; cfg.tx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE; cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_48000; cfg.def_method = RPC_AUD_DEF_METHOD_HOST_PCM; cfg.codec = RPC_AUD_DEF_CODEC_PCM; cfg.snd_method = RPC_SND_METHOD_MIDI; audio_prevent_sleep(audio); rc = audmgr_enable(&audio->audmgr, &cfg); if (rc < 0) { audio_allow_sleep(audio); return rc; } #ifdef CONFIG_CCI_SPEAKER /*cci.johnny_lee, for pop-noise issue */ MM_INFO("[CLK] speaker_audmgr_enable(true)\n"); if (speaker_audmgr_enable(true) < 0) { MM_ERR("[CLK] speaker_audmgr_enable return failed, we will retry after 600ms\n"); } else { msleep(80); } #endif if (audpp_enable(-1, audio_dsp_event, audio)) { MM_ERR("audpp_enable() failed\n"); audmgr_disable(&audio->audmgr); audio_allow_sleep(audio); return -ENODEV; } audio->enabled = 1; htc_pwrsink_set(PWRSINK_AUDIO, 100); return 0; }
/* must be called with audio->lock held */ static int audio_enable(struct audio *audio) { struct audmgr_config cfg; int rc; MM_INFO("\n"); /* Macro prints the file name and function */ if (audio->enabled) return 0; /* refuse to start if we're not ready */ if (!audio->out[0].used || !audio->out[1].used) return -EIO; /* we start buffers 0 and 1, so buffer 0 will be the * next one the dsp will want */ audio->out_tail = 0; audio->out_needed = 0; cfg.tx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE; cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_48000; cfg.def_method = RPC_AUD_DEF_METHOD_HOST_PCM; cfg.codec = RPC_AUD_DEF_CODEC_PCM; cfg.snd_method = RPC_SND_METHOD_MIDI; audio_prevent_sleep(audio); rc = audmgr_enable(&audio->audmgr, &cfg); if (rc < 0) { audio_allow_sleep(audio); return rc; } #ifdef CONFIG_AMP_MAX97000 if(!audio_enabled) { audio_enabled = 1; //max97000_resume(); } #endif if (audpp_enable(-1, audio_dsp_event, audio)) { MM_ERR("audpp_enable() failed\n"); audmgr_disable(&audio->audmgr); audio_allow_sleep(audio); return -ENODEV; } audio->enabled = 1; htc_pwrsink_set(PWRSINK_AUDIO, 100); return 0; }
static int msm_pcm_capture_prepare(struct snd_pcm_substream *substream) { struct snd_pcm_runtime *runtime = substream->runtime; struct msm_audio *prtd = runtime->private_data; struct audmgr_config cfg; int rc; prtd->pcm_size = snd_pcm_lib_buffer_bytes(substream); prtd->pcm_count = snd_pcm_lib_period_bytes(substream); prtd->pcm_irq_pos = 0; prtd->pcm_buf_pos = 0; /* rate and channels are sent to audio driver */ prtd->samp_rate = convert_samp_rate(runtime->rate); prtd->samp_rate_index = convert_dsp_samp_index(runtime->rate); prtd->channel_mode = (runtime->channels - 1); prtd->buffer_size = prtd->channel_mode ? STEREO_DATA_SIZE : \ MONO_DATA_SIZE; if (prtd->enabled == 1) return 0; prtd->type = AUDREC_CMD_TYPE_0_INDEX_WAV; cfg.tx_rate = convert_samp_rate(runtime->rate); cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE; cfg.def_method = RPC_AUD_DEF_METHOD_RECORD; cfg.codec = RPC_AUD_DEF_CODEC_PCM; cfg.snd_method = RPC_SND_METHOD_MIDI; rc = audmgr_enable(&prtd->audmgr, &cfg); if (rc < 0) return rc; if (msm_adsp_enable(prtd->audpre)) { audmgr_disable(&prtd->audmgr); return -ENODEV; } if (msm_adsp_enable(prtd->audrec)) { msm_adsp_disable(prtd->audpre); audmgr_disable(&prtd->audmgr); return -ENODEV; } prtd->enabled = 1; alsa_rec_dsp_enable(prtd, 1); return 0; }
/* must be called with audio->lock held */ static int audevrc_in_enable(struct audio_evrc_in *audio) { struct audmgr_config cfg; int rc; if (audio->enabled) return 0; cfg.tx_rate = audio->samp_rate; cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE; cfg.def_method = RPC_AUD_DEF_METHOD_RECORD; cfg.codec = RPC_AUD_DEF_CODEC_EVRC; cfg.snd_method = RPC_SND_METHOD_MIDI; if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) { rc = audmgr_enable(&audio->audmgr, &cfg); if (rc < 0) return rc; if (audpreproc_enable(audio->enc_id, &audpre_dsp_event, audio)) { MM_ERR("msm_adsp_enable(audpreproc) failed\n"); audmgr_disable(&audio->audmgr); return -ENODEV; } /*update aurec session info in audpreproc layer*/ audio->session_info.session_id = audio->enc_id; audio->session_info.sampling_freq = convert_samp_index(audio->samp_rate); audpreproc_update_audrec_info(&audio->session_info); } if (msm_adsp_enable(audio->audrec)) { if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) { audpreproc_disable(audio->enc_id, audio); audmgr_disable(&audio->audmgr); } MM_ERR("msm_adsp_enable(audrec) failed\n"); return -ENODEV; } audio->enabled = 1; audevrc_in_dsp_enable(audio, 1); return 0; }
/* must be called with audio->lock held */ static int audio_enable(struct audio *audio) { struct audmgr_config cfg; int rc; pr_info("audio_enable()\n"); if (audio->enabled) return 0; /* refuse to start if we're not ready */ if (!audio->out[0].used || !audio->out[1].used) return -EIO; /* we start buffers 0 and 1, so buffer 0 will be the * next one the dsp will want */ audio->out_tail = 0; audio->out_needed = 0; cfg.tx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE; cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_48000; cfg.def_method = RPC_AUD_DEF_METHOD_HOST_PCM; cfg.codec = RPC_AUD_DEF_CODEC_PCM; cfg.snd_method = RPC_SND_METHOD_MIDI; audio_prevent_sleep(audio); rc = audmgr_enable(&audio->audmgr, &cfg); if (rc < 0) { audio_allow_sleep(audio); return rc; } if (audpp_enable(-1, audio_dsp_event, audio)) { pr_err("audio: audpp_enable() failed\n"); audmgr_disable(&audio->audmgr); audio_allow_sleep(audio); return -ENODEV; } audio->enabled = 1; htc_pwrsink_set(PWRSINK_AUDIO, 100); return 0; }
static int audpcm_in_enable(struct audio_in *audio) { struct audmgr_config cfg; int rc; if (audio->enabled) return 0; cfg.tx_rate = audio->samp_rate; cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE; cfg.def_method = RPC_AUD_DEF_METHOD_RECORD; cfg.codec = RPC_AUD_DEF_CODEC_PCM; cfg.snd_method = RPC_SND_METHOD_MIDI; rc = audmgr_enable(&audio->audmgr, &cfg); if (rc < 0) return rc; if (audpreproc_enable(audio->enc_id, &audpre_dsp_event, audio)) { MM_AUD_ERR("audrec: msm_adsp_enable(audpre) failed\n"); audmgr_disable(&audio->audmgr); return -ENODEV; } if (msm_adsp_enable(audio->audrec)) { audpreproc_disable(audio->enc_id, audio); audmgr_disable(&audio->audmgr); MM_AUD_ERR("audrec: msm_adsp_enable(audrec) failed\n"); return -ENODEV; } audio->enabled = 1; audpcm_in_dsp_enable(audio, 1); audio->session_info.session_id = audio->enc_id; audio->session_info.sampling_freq = convert_samp_index(audio->samp_rate); audpreproc_update_audrec_info(&audio->session_info); return 0; }
/* must be called with audio->lock held */ static int audaac_in_enable(struct audio_aac_in *audio) { struct audmgr_config cfg; int rc; if (audio->enabled) return 0; cfg.tx_rate = audio->samp_rate; cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE; cfg.def_method = RPC_AUD_DEF_METHOD_RECORD; cfg.codec = RPC_AUD_DEF_CODEC_AAC; cfg.snd_method = RPC_SND_METHOD_MIDI; if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) { rc = audmgr_enable(&audio->audmgr, &cfg); if (rc < 0) return rc; if (msm_adsp_enable(audio->audpre)) { audmgr_disable(&audio->audmgr); MM_ERR("msm_adsp_enable(audpre) failed\n"); return -ENODEV; } } if (msm_adsp_enable(audio->audrec)) { if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) { audmgr_disable(&audio->audmgr); msm_adsp_disable(audio->audpre); } MM_ERR("msm_adsp_enable(audrec) failed\n"); return -ENODEV; } audio->enabled = 1; audaac_in_dsp_enable(audio, 1); return 0; }
/* must be called with audio->lock held */ static int audio_enable(struct audio *audio) { struct audmgr_config cfg; int rc = 0; MM_DBG("\n"); /* Macro prints the file name and function */ if (audio->enabled) return 0; cfg.tx_rate = RPC_AUD_DEF_SAMPLE_RATE_48000; cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_48000; cfg.def_method = RPC_AUD_DEF_METHOD_HOST_PCM; cfg.codec = RPC_AUD_DEF_CODEC_PCM; cfg.snd_method = RPC_SND_METHOD_VOICE; rc = audmgr_enable(&audio->audmgr, &cfg); if (rc < 0) return rc; audio->enabled = 1; return rc; }
/* must be called with audio->lock held */ static int audvoicememo_enable(struct audio_voicememo *audio) { struct audmgr_config cfg; struct snd_voc_rec_put_buf_msg bmsg; struct snd_voc_rec_start_msg msg; uint8_t index; uint32_t offset = 0; int rc; if (audio->enabled) return 0; /* Codec / method configure to audmgr client */ cfg.tx_rate = RPC_AUD_DEF_SAMPLE_RATE_8000; cfg.rx_rate = RPC_AUD_DEF_SAMPLE_RATE_NONE; cfg.def_method = RPC_AUD_DEF_METHOD_RECORD; if (audio->voicememo_cfg.capability == RPC_VOC_CAP_IS733) cfg.codec = RPC_AUD_DEF_CODEC_VOC_13K; else if (audio->voicememo_cfg.capability == RPC_VOC_CAP_IS127) cfg.codec = RPC_AUD_DEF_CODEC_VOC_EVRC; else cfg.codec = RPC_AUD_DEF_CODEC_VOC_AMR; /* RPC_VOC_CAP_AMR */ cfg.snd_method = RPC_SND_METHOD_VOICE; rc = audmgr_enable(&audio->audmgr, &cfg); if (rc < 0) return rc; /* Configure VOC Rec buffer */ for (index = 0; index < MAX_REC_BUF_COUNT; index++) { audio->in[index].data = audio->rec_buf_ptr + offset; audio->in[index].addr = audio->phys + offset; audio->in[index].size = audio->rec_buf_size; audio->in[index].used = 0; audio->in[index].numframes = 0; offset += audio->rec_buf_size; bmsg.args.buf = (uint32_t) audio->in[index].data; bmsg.args.num_bytes = cpu_to_be32(audio->in[index].size); MM_DBG("rec_buf_ptr=0x%8x, rec_buf_size = 0x%8x\n", bmsg.args.buf, bmsg.args.num_bytes); msm_rpc_setup_req(&bmsg.hdr, audio->rpc_prog, audio->rpc_ver, SND_VOC_REC_PUT_BUF_PROC); audio->rpc_xid = bmsg.hdr.xid; audio->rpc_status = RPC_STATUS_FAILURE; msm_rpc_write(audio->sndept, &bmsg, sizeof(bmsg)); rc = wait_event_timeout(audio->wait, audio->rpc_status != RPC_STATUS_FAILURE, 1 * HZ); if (rc == 0) goto err; } /* Start Recording */ msg.args.param_status = cpu_to_be32(0x00000001); msg.args.rec_type = cpu_to_be32(audio->voicememo_cfg.rec_type); msg.args.rec_interval_ms = cpu_to_be32(audio->voicememo_cfg.rec_interval_ms); msg.args.auto_stop_ms = cpu_to_be32(audio->voicememo_cfg.auto_stop_ms); msg.args.capability = cpu_to_be32(audio->voicememo_cfg.capability); msg.args.max_rate = cpu_to_be32(audio->voicememo_cfg.max_rate); msg.args.min_rate = cpu_to_be32(audio->voicememo_cfg.min_rate); msg.args.frame_format = cpu_to_be32(audio->voicememo_cfg.frame_format); msg.args.dtx_enable = cpu_to_be32(audio->voicememo_cfg.dtx_enable); msg.args.data_req_ms = cpu_to_be32(audio->voicememo_cfg.data_req_ms); msg.args.rec_client_data = cpu_to_be32(REC_CLIENT_DATA); msg.args.cb_func_id = cpu_to_be32(DATA_CB_FUNC_ID); msg.args.sync_cb_func_id = cpu_to_be32(AV_SYNC_CB_FUNC_ID); msg.args.client_data = cpu_to_be32(CLIENT_DATA); msm_rpc_setup_req(&msg.hdr, audio->rpc_prog, audio->rpc_ver, SND_VOC_REC_START_PROC); audio->rpc_xid = msg.hdr.xid; audio->rpc_status = RPC_STATUS_FAILURE; msm_rpc_write(audio->sndept, &msg, sizeof(msg)); rc = wait_event_timeout(audio->wait, audio->rpc_status != RPC_STATUS_FAILURE, 1 * HZ); if (rc == 0) goto err; audio->rpc_xid = 0; audio->enabled = 1; return 0; err: audio->rpc_xid = 0; audmgr_disable(&audio->audmgr); MM_ERR("Fail\n"); return -1; }