Example #1
0
/* must be called with audio->lock held */
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 (msm_adsp_enable(audio->audpre)) {
		MM_ERR("msm_adsp_enable(audpre) failed\n");
		audmgr_disable(&audio->audmgr);
		return -ENODEV;
	}
	if (msm_adsp_enable(audio->audrec)) {
		audmgr_disable(&audio->audmgr);
		msm_adsp_disable(audio->audpre);
		MM_ERR("msm_adsp_enable(audrec) failed\n");
		return -ENODEV;
	}

	audio->enabled = 1;
	audpcm_in_dsp_enable(audio, 1);

	return 0;
}
Example #2
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;
}
Example #3
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_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;
}
Example #5
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_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;
}
Example #7
0
/* 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_disable(struct audio *audio)
{
	MM_DBG("\n"); /* Macro prints the file name and function */
	if (audio->enabled) {
		audio->enabled = 0;
		audmgr_disable(&audio->audmgr);
	}
	return 0;
}
Example #9
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 audio_amrnb_in_disable(struct audio_amrnb_in *audio)
{
	if (audio->enabled) {
		audio->enabled = 0;
		audio_amrnb_in_dsp_enable(audio, 0);
		wake_up(&audio->wait);
		audrectask_disable(audio->enc_type, audio);
		audmgr_disable(&audio->audmgr);
	}
	return 0;
}
/* must be called with audio->lock held */
static int audamrnb_in_enable(struct audio_amrnb_in *audio)
{
	struct audmgr_config cfg;
	int32_t 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_AMR_NB;
	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;
	audamrnb_in_dsp_enable(audio, 1);

	return 0;
}
Example #12
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;
}
Example #13
0
int audio_disable(struct msm_audio *prtd)
{
	if (prtd->enabled) {
		mutex_lock(&the_locks.lock);
		prtd->enabled = 0;
		audio_dsp_out_enable(prtd, 0);
		wake_up(&the_locks.write_wait);
		audpp_disable(AUDPP_ALSA_DECODER, prtd);
		audmgr_disable(&prtd->audmgr);
		prtd->out_needed = 0;
		mutex_unlock(&the_locks.lock);
	}
	return 0;
}
Example #14
0
/* must be called with audio->lock held */
static int audio_in_disable(struct audio_in *audio)
{
	if (audio->enabled) {
		audio->enabled = 0;

		audio_in_dsp_enable(audio, 0);

		wake_up(&audio->wait);

		msm_adsp_disable(audio->audrec);
		msm_adsp_disable(audio->audpre);
		audmgr_disable(&audio->audmgr);
	}
	return 0;
}
/* must be called with audio->lock held */
static int audvoicememo_disable(struct audio_voicememo *audio)
{
    struct rpc_request_hdr rhdr;
    int rc = 0;
    if (audio->enabled) {
        msm_rpc_setup_req(&rhdr, audio->rpc_prog, audio->rpc_ver,
                          SND_VOC_REC_STOP_PROC);
        rc = msm_rpc_write(audio->sndept, &rhdr, sizeof(rhdr));
        wait_event_timeout(audio->wait, audio->stopped == 0,
                           1 * HZ);
        wake_up(&audio->read_wait);
        audmgr_disable(&audio->audmgr);
        audio->enabled = 0;
    }
    return 0;
}
Example #16
0
static int audio_disable(struct audio *audio)
{
	pr_info("audio_disable()\n");
	if (audio->enabled) {
		audio->enabled = 0;
		audio_dsp_out_enable(audio, 0);

		audpp_disable(-1, audio);

		wake_up(&audio->wait);
		audmgr_disable(&audio->audmgr);
		audio->out_needed = 0;
		audio_allow_sleep(audio);
	}
	return 0;
}
/* must be called with audio->lock held */
static int audio_disable(struct audio *audio)
{
	MM_DBG("\n"); /* Macro prints the file name and function */
	if (audio->enabled) {
		audio->enabled = 0;
		audio_dsp_out_enable(audio, 0);

		audpp_disable(-1, audio);

		wake_up(&audio->wait);
		audmgr_disable(&audio->audmgr);
		audio->out_needed = 0;
		audio_allow_sleep(audio);
	}
	return 0;
}
Example #18
0
int audrec_disable(struct msm_audio *prtd)
{
	if (prtd->enabled) {
		mutex_lock(&the_locks.lock);
		prtd->enabled = 0;
		audrec_dsp_enable(prtd, 0);
		wake_up(&the_locks.read_wait);
		msm_adsp_disable(prtd->audpre);
		msm_adsp_disable(prtd->audrec);
		audmgr_disable(&prtd->audmgr);
		prtd->out_needed = 0;
		prtd->opened = 0;
		mutex_unlock(&the_locks.lock);
	}
	return 0;
}
/* must be called with audio->lock held */
static int audaac_in_disable(struct audio_aac_in *audio)
{
	if (audio->enabled) {
		audio->enabled = 0;

		audaac_in_dsp_enable(audio, 0);

		wake_up(&audio->wait);
		wait_event_interruptible_timeout(audio->wait_enable,
				audio->running == 0, 1*HZ);
		msm_adsp_disable(audio->audrec);
		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
			msm_adsp_disable(audio->audpre);
			audmgr_disable(&audio->audmgr);
		}
	}
	return 0;
}
Example #20
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;
}
Example #21
0
static int audpcm_in_disable(struct audio_in *audio)
{
	if (audio->enabled) {
		audio->enabled = 0;

		audpcm_in_dsp_enable(audio, 0);

		audio->stopped = 1;
		wake_up(&audio->wait);

		msm_adsp_disable(audio->audrec);
		audpreproc_disable(audio->enc_id, audio);
		
		audio->session_info.sampling_freq = 0;
		audpreproc_update_audrec_info(&audio->session_info);
		audmgr_disable(&audio->audmgr);
	}
	return 0;
}
/* must be called with audio->lock held */
static int audio_disable(struct audio *audio)
{
	MM_DBG("\n"); /* Macro prints the file name and function */
	if (audio->enabled) {
		MM_AUD_INFO("audio_disable()\n");
		audio->enabled = 0;
		audio_dsp_out_enable(audio, 0);

		audpp_disable(-1, audio);

		audio->stopped = 1;
		wake_up(&audio->wait);
		audmgr_disable(&audio->audmgr);
		audio->out_needed = 0;
		audio_allow_sleep(audio);
		htc_pwrsink_audio_set(PWRSINK_AUDIO_PCM, 0);
	}
	return 0;
}
Example #23
0
/* must be called with audio->lock held */
static int audio_disable(struct audio *audio)
{
	MM_INFO("\n"); /* Macro prints the file name and function */
	if (audio->enabled) {
		audio->enabled = 0;
		
		isAudioEn = 0;			//JRD added.
		audio_opal_spkr_pa_enable();

		audio_dsp_out_enable(audio, 0);

		audpp_disable(-1, audio);

		wake_up(&audio->wait);
		audmgr_disable(&audio->audmgr);
		audio->out_needed = 0;
		audio_allow_sleep(audio);
	}
	return 0;
}
Example #24
0
/* must be called with audio->lock held */
static int audio_disable(struct audio *audio)
{
	MM_INFO("\n"); /* Macro prints the file name and function */
	if (audio->enabled) {

#ifdef CONFIG_AMP_MAX97000
		audio_enabled = 0;
		//max97000_suspend();
#endif
		audio->enabled = 0;
		audio_dsp_out_enable(audio, 0);

		audpp_disable(-1, audio);

		wake_up(&audio->wait);
		audmgr_disable(&audio->audmgr);
		audio->out_needed = 0;
		audio_allow_sleep(audio);
	}
	return 0;
}
/* must be called with audio->lock held */
static int audio_disable(struct audio *audio)
{
    MM_DBG("\n"); /* Macro prints the file name and function */
    if (audio->enabled) {
        audio->enabled = 0;
//added by john
        isAudioEn = audio->enabled;
        if(!isIncallMode) {
            audio_opal_spkr_pa_enable(false);
        }
//added by john
        audio_dsp_out_enable(audio, 0);

        audpp_disable(-1, audio);

        wake_up(&audio->wait);
        audmgr_disable(&audio->audmgr);
        audio->out_needed = 0;
        audio_allow_sleep(audio);
    }
    return 0;
}
/* must be called with audio->lock held */
static int audio_disable(struct audio *audio)
{
	if (audio->enabled) {
		pr_info("audio_mp3_disable()\n");
		audio->enabled = 0;
		auddec_dsp_config(audio, 0);
		wake_up(&audio->wait);
		audpp_disable(audio->dec_id, audio);
		msm_adsp_disable(audio->audplay);
		msm_adsp_put(audio->audplay);
		audmgr_disable(&audio->audmgr);
		atomic_set(&audio->image_swap, 0);
		audio->sent_bytes = 0;
		audio->consumed_bytes = 0;
		audio->total_consumed_bytes = 0;
		audio->out_needed = 0;
		audio->paused = 0;
		audio_allow_sleep(audio);
		htc_pwrsink_audio_set(PWRSINK_AUDIO_MP3, 0);
	}
	return 0;
}
Example #27
0
/* must be called with audio->lock held */
static int audamrnb_in_disable(struct audio_amrnb_in *audio)
{
	if (audio->enabled) {
		audio->enabled = 0;

		audamrnb_in_dsp_enable(audio, 0);

		wake_up(&audio->wait);
		wait_event_interruptible_timeout(audio->wait_enable,
				audio->running == 0, 1*HZ);
		msm_adsp_disable(audio->audrec);
		if (audio->mode == MSM_AUD_ENC_MODE_TUNNEL) {
			/*reset the sampling frequency information at
			audpreproc layer*/
			audio->session_info.sampling_freq = 0;
			audpreproc_update_audrec_info(&audio->session_info);
			audpreproc_disable(audio->enc_id, audio);
			audmgr_disable(&audio->audmgr);
		}
	}
	return 0;
}
/* must be called with audio->lock held */
static int audpcm_in_disable(struct audio_in *audio)
{
	int rc;

	if (audio->enabled) {
		audio->enabled = 0;

		audpcm_in_dsp_enable(audio, 0);

		audio->stopped = 1;
		wake_up(&audio->wait);

		msm_adsp_disable(audio->audrec);
		audpreproc_disable(audio->enc_id, audio);
		/*reset the sampling frequency information at audpreproc layer*/
		audio->session_info.sampling_freq = 0;
		audpreproc_update_audrec_info(&audio->session_info);
		rc = audmgr_disable(&audio->audmgr);
		if (rc < 0)
			msm_adsp_dump(audio->audrec);
	}
	return 0;
}
Example #29
0
/* must be called with audio->lock held */
static int audio_disable(struct audio *audio)
{
	MM_INFO("[CLK]\n"); /* Macro prints the file name and function */
	if (audio->enabled) {
		audio->enabled = 0;
#ifdef CONFIG_CCI_SPEAKER
	MM_INFO("[CLK] speaker_audmgr_enable(false)\n");
	/*cci.johnny_lee, for pop-noise issue */
	if (speaker_audmgr_enable(false) < 0)
	{
		MM_ERR("[CLK] speaker_audmgr_enable return failed, we will retry after 600ms\n");
	}
#endif
		audio_dsp_out_enable(audio, 0);

		audpp_disable(-1, audio);

		wake_up(&audio->wait);
		audmgr_disable(&audio->audmgr);
		audio->out_needed = 0;
		audio_allow_sleep(audio);
	}
	return 0;
}
/* 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;
}